-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.test.mjs
42 lines (35 loc) · 1.16 KB
/
node.test.mjs
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
import assert from 'node:assert';
import { describe, it } from 'node:test';
describe('package exports', () => {
it('should contain all components', async () => {
const comps = await import('form5/react');
assert.ok(comps.Button, 'Button');
assert.ok(comps.Field, 'Field');
assert.ok(comps.FileInput, 'FileInput');
assert.ok(comps.Form, 'Form');
assert.strictEqual(Object.keys(comps).length, 4, 'number of components');
});
it('should contain all utilities', async () => {
await import('form5/composeData')
.then(assert.ok);
await import('form5/deepDiff')
.then(assert.ok);
});
});
describe('importing exports', () => {
it('should import each component', async () => {
const imports = await Promise.all([
import('form5/composeData'),
import('form5/deepDiff'),
import('form5/react/Button'),
import('form5/react/Field'),
import('form5/react/FileInput'),
]);
for (const imp of imports) {
assert.strictEqual(typeof imp.default, 'function', 'default export');
}
// Form is memoized, so it's wrapped
await import('form5/react/Form')
.then((imp) => assert.strictEqual(typeof imp.default.type, 'function', 'default export'))
});
});