|
1 | 1 | // Function. |
2 | 2 | import { isInstance } from '../lib/is-instance.func'; |
3 | | -// Variables. |
| 3 | +// Constant. |
4 | 4 | import { FALSE, TRUE, FALSE_INSTANCE, TRUE_INSTANCE } from '../../testing/variables/boolean.const'; |
5 | 5 | import { BIGINT, BIGINT_INSTANCE } from '../../testing/variables/big-int.const'; |
6 | | -import { Class, CLASS, PERSON, Person, PersonCopy, PERSON_COPY } from '../../testing/variables/class.const'; |
7 | | -import { FUNCTION } from '../../testing/variables/function.const'; |
| 6 | +import { Class, CLASS, PERSON, Persons, PersonCopy, PERSON_COPY } from '../../testing/variables/class.const'; |
| 7 | +import { FUNCTION, functionConstructor } from '../../testing/variables/function.const'; |
8 | 8 | import { NULL } from '../../testing/variables/null.const'; |
9 | 9 | import { NUMBER, NUMBER_INSTANCE, NUMBER_NEW_INSTANCE } from '../../testing/variables/number.const'; |
10 | 10 | import { STRING, STRING_INSTANCE, STRING_NEW_INSTANCE } from '../../testing/variables/string.const'; |
11 | 11 | import { UNDEFINED } from '../../testing/variables/undefined.const'; |
12 | 12 | import { notDefined } from '../../testing/variables/not-defined.const'; |
13 | | - |
| 13 | +/** |
| 14 | + * Tests. |
| 15 | + */ |
14 | 16 | describe(isInstance.name, () => { |
| 17 | + const anyInstance: any = new (functionConstructor as any)('First name', 'Sur name', 27); |
15 | 18 | // TRUE. |
16 | 19 | it('is DEFINED', () => expect(isInstance).toBeDefined()); |
17 | 20 | it(`CLASS instance of Class`, () => expect(isInstance(CLASS, Class)).toBe(TRUE)); |
18 | | - it(`PERSON instance of Person`, () => expect(isInstance(PERSON, Person)).toBe(TRUE)); |
| 21 | + it(`PERSON instance of Person`, () => expect(isInstance(PERSON, Persons)).toBe(TRUE)); |
19 | 22 | it(`PERSON_COPY instance of PersonCopy`, () => expect(isInstance(PERSON_COPY, PersonCopy)).toBe(TRUE)); |
20 | 23 | it(`CLASS instance of Class expect result to be true`, () => { |
21 | 24 | isInstance(CLASS, Class, (result: boolean) => { |
22 | 25 | expect(result).toBe(TRUE); |
23 | 26 | return result; |
24 | 27 | }); |
25 | 28 | }); |
| 29 | + it(`function constructor`, () => expect(isInstance(anyInstance, functionConstructor as any)).toBe(TRUE)); |
26 | 30 |
|
27 | 31 | // FALSE. |
28 | | - it(`PERSON_COPY not instance of Person`, () => expect(isInstance(PERSON_COPY, Person)).toBe(FALSE)); |
| 32 | + it(`PERSON_COPY not instance of Person`, () => expect(isInstance(PERSON_COPY, Persons)).toBe(FALSE)); |
29 | 33 | it(`'boolean' | Boolean`, () => { |
30 | 34 | expect(isInstance(FALSE, FALSE)).toBe(FALSE); |
31 | 35 | expect(isInstance(TRUE, TRUE)).toBe(FALSE); |
|
0 commit comments