mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-11 00:36:26 +00:00
Add jest and simple test
This commit is contained in:
2
.babelrc
2
.babelrc
@@ -5,7 +5,7 @@
|
||||
"presets": ["react-hmre"]
|
||||
},
|
||||
"test": {
|
||||
"presets": ["react", "es2015"],
|
||||
"presets": ["env" ,"react", "es2015"],
|
||||
"plugins": [
|
||||
[ "babel-plugin-webpack-alias", { "config": "${PWD}/webpack.config.js" } ]
|
||||
]
|
||||
|
||||
7
__mocks__/electron.js
Normal file
7
__mocks__/electron.js
Normal file
@@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
require: jest.genMockFunction(),
|
||||
match: jest.genMockFunction(),
|
||||
app: jest.genMockFunction(),
|
||||
remote: jest.genMockFunction(),
|
||||
dialog: jest.genMockFunction()
|
||||
}
|
||||
14
package.json
14
package.json
@@ -11,6 +11,7 @@
|
||||
"webpack": "webpack-dev-server --hot --inline --config webpack.config.js",
|
||||
"compile": "grunt compile",
|
||||
"test": "PWD=$(pwd) NODE_ENV=test ava --serial",
|
||||
"jest": "jest",
|
||||
"fix": "npm run lint --fix",
|
||||
"lint": "eslint .",
|
||||
"dev-start": "concurrently --kill-others \"npm run webpack\" \"npm run hot\""
|
||||
@@ -96,11 +97,13 @@
|
||||
"devDependencies": {
|
||||
"ava": "^0.25.0",
|
||||
"babel-core": "^6.14.0",
|
||||
"babel-jest": "^22.4.3",
|
||||
"babel-loader": "^6.2.0",
|
||||
"babel-plugin-react-transform": "^2.0.0",
|
||||
"babel-plugin-webpack-alias": "^2.1.1",
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"babel-preset-es2015": "^6.3.13",
|
||||
"babel-preset-react": "^6.3.13",
|
||||
"babel-preset-react": "^6.24.1",
|
||||
"babel-preset-react-hmre": "^1.0.1",
|
||||
"babel-register": "^6.11.6",
|
||||
"browser-env": "^3.2.5",
|
||||
@@ -120,6 +123,8 @@
|
||||
"grunt": "^0.4.5",
|
||||
"grunt-electron-installer": "2.1.0",
|
||||
"history": "^1.17.0",
|
||||
"identity-obj-proxy": "^3.0.0",
|
||||
"jest": "^22.4.3",
|
||||
"jsdom": "^9.4.2",
|
||||
"json-loader": "^0.5.4",
|
||||
"merge-stream": "^1.0.0",
|
||||
@@ -130,6 +135,7 @@
|
||||
"react-input-autosize": "^1.1.0",
|
||||
"react-router": "^2.4.0",
|
||||
"react-router-redux": "^4.0.4",
|
||||
"react-test-renderer": "^15.6.2",
|
||||
"standard": "^8.4.0",
|
||||
"style-loader": "^0.12.4",
|
||||
"stylus": "^0.52.4",
|
||||
@@ -152,5 +158,11 @@
|
||||
"./tests/helpers/setup-electron-mock.js"
|
||||
],
|
||||
"babel": "inherit"
|
||||
},
|
||||
"jest": {
|
||||
"moduleNameMapper": {
|
||||
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
|
||||
"\\.(css|less|styl)$": "identity-obj-proxy"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
9
tests/components/TagListItem.snapshot.test.js
Normal file
9
tests/components/TagListItem.snapshot.test.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import React from 'react'
|
||||
import renderer from 'react-test-renderer'
|
||||
import TagListItem from 'browser/components/TagListItem'
|
||||
|
||||
it('TagListItem renders correctly', () => {
|
||||
const tagListItem = renderer.create(<TagListItem name='Test' handleClickTagListItem={jest.fn()} />)
|
||||
|
||||
expect(tagListItem.toJSON()).toMatchSnapshot()
|
||||
})
|
||||
@@ -0,0 +1,19 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`TagListItem renders correctly 1`] = `
|
||||
<button
|
||||
className="tagList-item"
|
||||
onClick={[Function]}
|
||||
>
|
||||
<span
|
||||
className="tagList-item-name"
|
||||
>
|
||||
# Test
|
||||
<span
|
||||
className="tagList-item-count"
|
||||
>
|
||||
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
`;
|
||||
Reference in New Issue
Block a user