-
Notifications
You must be signed in to change notification settings - Fork 0
/
isAsyncFunction.test.ts
124 lines (103 loc) · 3.56 KB
/
isAsyncFunction.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/**
* ❌: The expectation should be equal to false
* ✅: The expectation should be equal to true
* ➖: The expectation can be equal to true or false
*/
import { describe, it, expect } from 'vitest';
import values from '../__Fixtures/values.js';
import isAsyncFunction from '../../src/isAsyncFunction.js';
const KEY = 'asyncFunctions';
// eslint-disable-next-line @typescript-eslint/no-empty-function
const AsyncFunctionConstructor = Object.getPrototypeOf(async () => {}).constructor;
describe('is/isAsyncFunction', () => {
it(`❌ nil !== ${KEY}`, () => {
values.nil.forEach((value) => {
expect(isAsyncFunction(value)).toEqual(false);
});
});
it(`❌ booleans !== ${KEY}`, () => {
values.booleans.forEach((value) => {
expect(isAsyncFunction(value)).toEqual(false);
});
});
it(`❌ integers !== ${KEY}`, () => {
values.integers.forEach((value) => {
expect(isAsyncFunction(value)).toEqual(false);
});
});
it(`❌ floats !== ${KEY}`, () => {
values.floats.forEach((value) => {
expect(isAsyncFunction(value)).toEqual(false);
});
});
it(`❌ numbers !== ${KEY}`, () => {
values.numbers.forEach((value) => {
expect(isAsyncFunction(value)).toEqual(false);
});
});
it(`❌ bigInts !== ${KEY}`, () => {
values.bigInts.forEach((value) => {
expect(isAsyncFunction(value)).toEqual(false);
});
});
it(`❌ strings !== ${KEY}`, () => {
values.strings.forEach((value) => {
expect(isAsyncFunction(value)).toEqual(false);
});
});
it(`❌ symbols !== ${KEY}`, () => {
values.symbols.forEach((value) => {
expect(isAsyncFunction(value)).toEqual(false);
});
});
it(`❌ arrays !== ${KEY}`, () => {
values.arrays.forEach((value) => {
expect(isAsyncFunction(value)).toEqual(false);
});
});
it(`❌ DOM elements !== ${KEY}`, () => {
values.elements.forEach((value) => {
expect(isAsyncFunction(value)).toEqual(false);
});
});
it(`❌ DOM nodeLists !== ${KEY}`, () => {
values.nodeLists.forEach((value) => {
expect(isAsyncFunction(value)).toEqual(false);
});
});
it(`❌ DOM alternative contexts !== ${KEY}`, () => {
values.alternativeDOMs.forEach((value) => {
expect(isAsyncFunction(value)).toEqual(false);
});
});
it(`➖ functions !== || === ${KEY}`, () => {
values.functions.forEach((value) => {
expect(isAsyncFunction(value)).toEqual(value.constructor === AsyncFunctionConstructor);
});
});
it(`❌ classes !== ${KEY}`, () => {
values.classes.forEach((value) => {
expect(isAsyncFunction(value)).toEqual(false);
});
});
it(`❌ object constructors !== ${KEY}`, () => {
values.constructors.forEach((value) => {
expect(isAsyncFunction(value)).toEqual(false);
});
});
it(`❌ invoked object constructors !== ${KEY}`, () => {
values.invokedConstructors.forEach((value) => {
expect(isAsyncFunction(value)).toEqual(false);
});
});
it(`❌ object instances !== ${KEY}`, () => {
values.instances.forEach((value) => {
expect(isAsyncFunction(value)).toEqual(false);
});
});
it(`❌ objects !== ${KEY}`, () => {
values.objects.forEach((value) => {
expect(isAsyncFunction(value)).toEqual(false);
});
});
});