Skip to content

Commit 8cdab5d

Browse files
test(isInstance): add tests for function constructor
1 parent 6dd058c commit 8cdab5d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/is/test/is-instance.spec.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
11
// Function.
22
import { isInstance } from '../lib/is-instance.func';
3-
// Variables.
3+
// Constant.
44
import { FALSE, TRUE, FALSE_INSTANCE, TRUE_INSTANCE } from '../../testing/variables/boolean.const';
55
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';
88
import { NULL } from '../../testing/variables/null.const';
99
import { NUMBER, NUMBER_INSTANCE, NUMBER_NEW_INSTANCE } from '../../testing/variables/number.const';
1010
import { STRING, STRING_INSTANCE, STRING_NEW_INSTANCE } from '../../testing/variables/string.const';
1111
import { UNDEFINED } from '../../testing/variables/undefined.const';
1212
import { notDefined } from '../../testing/variables/not-defined.const';
13-
13+
/**
14+
* Tests.
15+
*/
1416
describe(isInstance.name, () => {
17+
const anyInstance: any = new (functionConstructor as any)('First name', 'Sur name', 27);
1518
// TRUE.
1619
it('is DEFINED', () => expect(isInstance).toBeDefined());
1720
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));
1922
it(`PERSON_COPY instance of PersonCopy`, () => expect(isInstance(PERSON_COPY, PersonCopy)).toBe(TRUE));
2023
it(`CLASS instance of Class expect result to be true`, () => {
2124
isInstance(CLASS, Class, (result: boolean) => {
2225
expect(result).toBe(TRUE);
2326
return result;
2427
});
2528
});
29+
it(`function constructor`, () => expect(isInstance(anyInstance, functionConstructor as any)).toBe(TRUE));
2630

2731
// 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));
2933
it(`'boolean' | Boolean`, () => {
3034
expect(isInstance(FALSE, FALSE)).toBe(FALSE);
3135
expect(isInstance(TRUE, TRUE)).toBe(FALSE);

0 commit comments

Comments
 (0)