misc_pterodactyl-panel/resources/scripts/lib/objects.spec.ts

25 lines
784 B
TypeScript
Raw Normal View History

2022-11-25 20:25:03 +00:00
import { describe, expect, it } from 'vitest';
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-11-25 20:25:03 +00:00
it('should return false for null', () => {
expect(isObject(null)).equals(false);
});
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);
},
);
});
});