Skip to content

Commit 3a2f26e

Browse files
Merge pull request #164 from remarkablemark/test/jest
test: migrate from mocha to jest
2 parents 179f359 + e7c5079 commit 3a2f26e

16 files changed

+468
-456
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"env": {
33
"browser": true,
44
"commonjs": true,
5-
"mocha": true,
5+
"jest": true,
66
"node": true
77
},
88
"extends": "eslint:recommended",

.huskyrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"hooks": {
33
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
4-
"pre-commit": "npm run lint:dts && npm run test:coverage && lint-staged"
4+
"pre-commit": "npm run lint:dts && npm run test:ci && lint-staged"
55
}
66
}

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ script:
88
- npx commitlint --from=HEAD~1
99
- npm run lint
1010
- npm run lint:dts
11-
- npm run test:coverage
11+
- npm run test:ci
1212
- npm run build
1313
- npm run benchmark
1414
after_success:
15-
- npx nyc report --reporter=text-lcov | npx coveralls
15+
- cat coverage/lcov.info | npx coveralls
1616
cache:
1717
directories:
1818
- node_modules

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
"lint": "eslint --ignore-path .gitignore --ignore-pattern /examples/ .",
1212
"lint:dts": "dtslint .",
1313
"lint:fix": "npm run lint -- --fix",
14-
"prepublishOnly": "npm run lint && npm run lint:dts && npm test && npm run clean && npm run build",
14+
"prepublishOnly": "npm run lint && npm run lint:dts && npm run test:ci && npm run clean && npm run build",
1515
"release": "standard-version --no-verify",
16-
"test": "mocha",
17-
"test:coverage": "nyc npm test",
18-
"test:coverage:report": "nyc report --reporter=html"
16+
"test": "jest --coverage",
17+
"test:ci": "npm test -- --ci",
18+
"test:watch": "npm test -- --watch"
1919
},
2020
"repository": {
2121
"type": "git",
@@ -49,9 +49,8 @@
4949
"eslint": "^7.1.0",
5050
"eslint-plugin-prettier": "^3.1.3",
5151
"husky": "^4.2.5",
52+
"jest": "^26.0.1",
5253
"lint-staged": "^10.2.7",
53-
"mocha": "^7.2.0",
54-
"nyc": "^15.1.0",
5554
"preact": "^10.4.4",
5655
"prettier": "^2.0.5",
5756
"react": "^16",
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`DOM to React converts <textarea> correctly 1`] = `
4+
<textarea
5+
defaultValue="foo"
6+
/>
7+
`;
8+
9+
exports[`DOM to React converts SVG element with viewBox attribute 1`] = `
10+
<svg
11+
id="foo"
12+
viewBox="0 0 512 512"
13+
>
14+
Inner
15+
</svg>
16+
`;
17+
18+
exports[`DOM to React converts multiple DOM nodes to React 1`] = `
19+
Array [
20+
<p>
21+
foo
22+
</p>,
23+
<p>
24+
bar
25+
</p>,
26+
]
27+
`;
28+
29+
exports[`DOM to React converts single DOM node to React 1`] = `
30+
<p>
31+
foo
32+
</p>
33+
`;
34+
35+
exports[`DOM to React does not escape <script> content 1`] = `
36+
<script
37+
dangerouslySetInnerHTML={
38+
Object {
39+
"__html": "alert(1 < 2);",
40+
}
41+
}
42+
/>
43+
`;
44+
45+
exports[`DOM to React does not escape <style> content 1`] = `
46+
<style
47+
dangerouslySetInnerHTML={
48+
Object {
49+
"__html": "body > .foo { color: #f00; }",
50+
}
51+
}
52+
/>
53+
`;
54+
55+
exports[`DOM to React does not modify attributes on custom elements 1`] = `
56+
<custom-button
57+
class="myClass"
58+
custom-attribute="value"
59+
/>
60+
`;
61+
62+
exports[`DOM to React skips doctype and comments 1`] = `
63+
Array [
64+
<p>
65+
foo
66+
</p>,
67+
<p>
68+
foo
69+
</p>,
70+
]
71+
`;
72+
73+
exports[`DOM to React when React <16 removes unknown attributes 1`] = `
74+
<custom-button
75+
className="myClass"
76+
/>
77+
`;
78+
79+
exports[`DOM to React when React >=16 preserves unknown attributes 1`] = `
80+
<custom-button
81+
class="myClass"
82+
custom-attribute="value"
83+
/>
84+
`;

0 commit comments

Comments
 (0)