Skip to content

test: migrate from mocha to jest #164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"env": {
"browser": true,
"commonjs": true,
"mocha": true,
"jest": true,
"node": true
},
"extends": "eslint:recommended",
Expand Down
2 changes: 1 addition & 1 deletion .huskyrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "npm run lint:dts && npm run test:coverage && lint-staged"
"pre-commit": "npm run lint:dts && npm run test:ci && lint-staged"
}
}
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ script:
- npx commitlint --from=HEAD~1
- npm run lint
- npm run lint:dts
- npm run test:coverage
- npm run test:ci
- npm run build
- npm run benchmark
after_success:
- npx nyc report --reporter=text-lcov | npx coveralls
- cat coverage/lcov.info | npx coveralls
cache:
directories:
- node_modules
Expand Down
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"lint": "eslint --ignore-path .gitignore --ignore-pattern /examples/ .",
"lint:dts": "dtslint .",
"lint:fix": "npm run lint -- --fix",
"prepublishOnly": "npm run lint && npm run lint:dts && npm test && npm run clean && npm run build",
"prepublishOnly": "npm run lint && npm run lint:dts && npm run test:ci && npm run clean && npm run build",
"release": "standard-version --no-verify",
"test": "mocha",
"test:coverage": "nyc npm test",
"test:coverage:report": "nyc report --reporter=html"
"test": "jest --coverage",
"test:ci": "npm test -- --ci",
"test:watch": "npm test -- --watch"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -49,9 +49,8 @@
"eslint": "^7.1.0",
"eslint-plugin-prettier": "^3.1.3",
"husky": "^4.2.5",
"jest": "^26.0.1",
"lint-staged": "^10.2.7",
"mocha": "^7.2.0",
"nyc": "^15.1.0",
"preact": "^10.4.4",
"prettier": "^2.0.5",
"react": "^16",
Expand Down
84 changes: 84 additions & 0 deletions test/__snapshots__/dom-to-react.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DOM to React converts <textarea> correctly 1`] = `
<textarea
defaultValue="foo"
/>
`;

exports[`DOM to React converts SVG element with viewBox attribute 1`] = `
<svg
id="foo"
viewBox="0 0 512 512"
>
Inner
</svg>
`;

exports[`DOM to React converts multiple DOM nodes to React 1`] = `
Array [
<p>
foo
</p>,
<p>
bar
</p>,
]
`;

exports[`DOM to React converts single DOM node to React 1`] = `
<p>
foo
</p>
`;

exports[`DOM to React does not escape <script> content 1`] = `
<script
dangerouslySetInnerHTML={
Object {
"__html": "alert(1 < 2);",
}
}
/>
`;

exports[`DOM to React does not escape <style> content 1`] = `
<style
dangerouslySetInnerHTML={
Object {
"__html": "body > .foo { color: #f00; }",
}
}
/>
`;

exports[`DOM to React does not modify attributes on custom elements 1`] = `
<custom-button
class="myClass"
custom-attribute="value"
/>
`;

exports[`DOM to React skips doctype and comments 1`] = `
Array [
<p>
foo
</p>,
<p>
foo
</p>,
]
`;

exports[`DOM to React when React <16 removes unknown attributes 1`] = `
<custom-button
className="myClass"
/>
`;

exports[`DOM to React when React >=16 preserves unknown attributes 1`] = `
<custom-button
class="myClass"
custom-attribute="value"
/>
`;
Loading