2026-10-05 18:10:18 -04:00
|
|
|
import { describe, expect, it } from 'vitest';
|
2022-06-26 14:34:09 -04:00
|
|
|
import { isObject } from '@/lib/objects';
|
|
|
|
|
|
2026-10-08 16:53:20 -04:00
|
|
|
describe('@/lib/objects.ts', () => {
|
|
|
|
|
describe('isObject()', () => {
|
|
|
|
|
it('should return true for objects', () => {
|
2022-06-26 14:34:09 -04:00
|
|
|
expect(isObject({})).toBe(true);
|
|
|
|
|
expect(isObject({ foo: 123 })).toBe(true);
|
|
|
|
|
expect(isObject(Object.freeze({}))).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
|
2026-10-08 16:53:20 -04:00
|
|
|
it('should return false for null', () => {
|
2022-06-26 14:34:09 -04:00
|
|
|
expect(isObject(null)).toBe(false);
|
|
|
|
|
});
|
|
|
|
|
|
2022-06-26 15:13:52 -04:00
|
|
|
it.each([undefined, 123, 'foobar', () => ({}), Function, String(123), isObject, () => null, [], [1, 2, 3]])(
|
|
|
|
|
'should return false for %p',
|
2026-10-08 16:53:20 -04:00
|
|
|
(value) => {
|
2022-06-26 15:13:52 -04:00
|
|
|
expect(isObject(value)).toBe(false);
|
|
|
|
|
}
|
|
|
|
|
);
|
2022-06-26 14:34:09 -04:00
|
|
|
});
|
|
|
|
|
});
|