Files
Sergei Zharinov 930cf6633c refactor: Rewrite imports with .ts extensions (#40700)
fix: Additional vi.mock path corrections and prettier formatting
2026-01-26 22:48:17 +00:00

31 lines
889 B
TypeScript

import { coerceObject, hasKey } from './object.ts';
describe('util/object', () => {
it('finds key in regular object', () => {
expect(hasKey('foo', { foo: true })).toBeTrue();
});
it('detects missing key in regular object', () => {
expect(hasKey('foo', { bar: true })).toBeFalse();
});
it('returns false for wrong instance type', () => {
expect(hasKey('foo', 'i-am-not-an-object')).toBeFalse();
});
describe('coerceObject', () => {
it('should return empty object', () => {
expect(coerceObject(undefined)).toEqual({});
expect(coerceObject(null)).toEqual({});
});
it('should return input object', () => {
expect(coerceObject({})).toEqual({});
expect(coerceObject({ name: 'name' })).toEqual({ name: 'name' });
expect(coerceObject(undefined, { name: 'name' })).toEqual({
name: 'name',
});
});
});
});