2022-11-25 20:25:03 +00:00
|
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
|
2022-06-26 18:34:09 +00:00
|
|
|
import { isObject } from '@/lib/objects';
|
|
|
|
|
2022-11-25 20:25:03 +00:00
|
|
|
describe('@/lib/objects.ts', () => {
|
|
|
|
describe('isObject()', () => {
|
|
|
|
it('should return true for objects', () => {
|
|
|
|
expect(isObject({})).equals(true);
|
|
|
|
expect(isObject({ foo: 123 })).equals(true);
|
|
|
|
expect(isObject(Object.freeze({}))).equals(true);
|
2022-06-26 18:34:09 +00:00
|
|
|
});
|
|
|
|
|
2022-11-25 20:25:03 +00:00
|
|
|
it('should return false for null', () => {
|
|
|
|
expect(isObject(null)).equals(false);
|
2022-06-26 18:34:09 +00:00
|
|
|
});
|
|
|
|
|
2022-06-26 19:13:52 +00:00
|
|
|
it.each([undefined, 123, 'foobar', () => ({}), Function, String(123), isObject, () => null, [], [1, 2, 3]])(
|
|
|
|
'should return false for %p',
|
2022-11-25 20:25:03 +00:00
|
|
|
value => {
|
|
|
|
expect(isObject(value)).equals(false);
|
|
|
|
},
|
2022-06-26 19:13:52 +00:00
|
|
|
);
|
2022-06-26 18:34:09 +00:00
|
|
|
});
|
|
|
|
});
|