import { expectTypeOf } from 'expect-type'; import { GenericFunction, PlainObject, VoidFunction } from './aliases'; describe('GenericFunction', () => { it('should match any function', () => { expectTypeOf(() => undefined).toMatchTypeOf(); expectTypeOf((a: number) => a).toMatchTypeOf(); expectTypeOf((a: number, b: string) => a + b).toMatchTypeOf(); }); }); describe('PlainObject', () => { it('should match plain objects', () => { expectTypeOf({}).toMatchTypeOf(); expectTypeOf({ a: 1 }).toMatchTypeOf(); }); it('should NOT match built-in objects', () => { expectTypeOf(() => undefined).not.toMatchTypeOf(); expectTypeOf([]).not.toMatchTypeOf(); expectTypeOf([1, 2, 3]).not.toMatchTypeOf(); }); it('should NOT match primitive values', () => { expectTypeOf('test').not.toMatchTypeOf(); expectTypeOf(1).not.toMatchTypeOf(); expectTypeOf(BigInt(12345678)).not.toMatchTypeOf(); expectTypeOf(Symbol('test')).not.toMatchTypeOf(); expectTypeOf(undefined).not.toMatchTypeOf(); expectTypeOf(null).not.toMatchTypeOf(); }); }); describe('VoidFunction', () => { it('should match void functions', () => { expectTypeOf(() => undefined).toMatchTypeOf(); expectTypeOf(() => null).toMatchTypeOf(); expectTypeOf(() => {}).toMatchTypeOf(); }); it('should NOT match functions that return value', () => { expectTypeOf((a: number) => a).not.toMatchTypeOf(); expectTypeOf((a: number, b: string) => a + b).not.toMatchTypeOf(); }); });