Skip to content

Commit c9592d1

Browse files
Merge pull request #955 from remarkablemark/test/module
test(module): refactor module tests
2 parents 07995a0 + 72b0f28 commit c9592d1

File tree

4 files changed

+57
-19
lines changed

4 files changed

+57
-19
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ jobs:
2424
- name: Lint TypeScript declaration files
2525
run: npm run lint:dts
2626

27-
- name: Run unit tests
27+
- name: Run tests
2828
run: npm run test:ci
2929

30-
- name: Run ES modules tests
30+
- name: Run module tests
3131
run: npm run test:module
3232

3333
- name: Run integration tests

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"size-limit": "size-limit",
2727
"test": "jest --coverage --testPathIgnorePatterns test/integration/",
2828
"test:ci": "npm test -- --ci --colors",
29-
"test:module": "node --experimental-modules test/module/index.mjs",
29+
"test:module": "node --test test/module/",
3030
"test:integration": "npm run build && jest --env=jsdom test/integration/",
3131
"test:watch": "npm test -- --watch"
3232
},

test/module/index.mjs

Lines changed: 0 additions & 16 deletions
This file was deleted.

test/module/index.test.mjs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { describe, it } from 'node:test';
2+
3+
import assert from 'assert';
4+
import { isValidElement } from 'react';
5+
6+
import parse, {
7+
Comment,
8+
Element,
9+
ProcessingInstruction,
10+
Text,
11+
attributesToProps,
12+
domToReact,
13+
htmlToDOM
14+
} from '../../index.mjs';
15+
16+
describe('index', () => {
17+
it('exports "parse" function', () => {
18+
assert.strictEqual(typeof parse, 'function');
19+
});
20+
21+
it('parses HTML to React element', () => {
22+
assert.ok(isValidElement(parse('<p>text</p>')));
23+
});
24+
25+
it('exports "attributesToProps" function', () => {
26+
assert.strictEqual(typeof attributesToProps, 'function');
27+
});
28+
29+
it('exports "domToReact" function', () => {
30+
assert.strictEqual(typeof domToReact, 'function');
31+
});
32+
33+
it('exports "htmlToDOM" function', () => {
34+
assert.strictEqual(typeof htmlToDOM, 'function');
35+
});
36+
});
37+
38+
describe('domhandler', () => {
39+
it('exports "Comment" function', () => {
40+
assert.strictEqual(typeof Comment, 'function');
41+
});
42+
43+
it('exports "Element" function', () => {
44+
assert.strictEqual(typeof Element, 'function');
45+
});
46+
47+
it('exports "ProcessingInstruction" function', () => {
48+
assert.strictEqual(typeof ProcessingInstruction, 'function');
49+
});
50+
51+
it('exports "Text" function', () => {
52+
assert.strictEqual(typeof Text, 'function');
53+
});
54+
});

0 commit comments

Comments
 (0)