diff --git a/.babelrc b/.babelrc index 1f51d42f7..adbc9c378 100644 --- a/.babelrc +++ b/.babelrc @@ -11,5 +11,12 @@ ], "plugins": [ "babel-plugin-transform-class-properties" - ] + ], + "env": { + "test": { + "plugins": [ + "transform-es2015-modules-commonjs" + ] + } + } } diff --git a/.eslintrc.json b/.eslintrc.json index 1afa47836..8f3a0812b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -18,6 +18,7 @@ "env": { "es6": true, "browser": true, - "node": true + "node": true, + "jest": true } } diff --git a/js/Search.jsx b/js/Search.jsx index 1ce244134..fa2a8245f 100644 --- a/js/Search.jsx +++ b/js/Search.jsx @@ -4,7 +4,7 @@ import preload from '../data.json'; class Search extends Component { state = { - searchTerm: 'game' + searchTerm: '' }; handleSearchTermChange = event => { this.setState({ searchTerm: event.target.value }); @@ -13,7 +13,7 @@ class Search extends Component { return (
-

svideo

+

z-video

{ + const component = shallow(); + expect(component).toMatchSnapshot(); +}); diff --git a/js/__test__/__snapshots__/Search.test.jsx.snap b/js/__test__/__snapshots__/Search.test.jsx.snap new file mode 100644 index 000000000..6a941234b --- /dev/null +++ b/js/__test__/__snapshots__/Search.test.jsx.snap @@ -0,0 +1,141 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Search renders correctly 1`] = ` +
+
+

+ z-video +

+ +
+
+ + + + + + + + + + + + + + + +
+
+`; diff --git a/package.json b/package.json index e74606c20..0ec2a8d40 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,13 @@ "dev": "webpack-dev-server", "format": "prettier --write --single-quote --print-width=120 --parser=flow --tab-width=2 \"js/**/*.{js,jsx}\"", "lint": "eslint **/*.{js,jsx} --quiet", + "test": "jest", + "test:update": "jest -u", "watch": "webpack --watch" }, + "jest": { + "snapshotSerializers": ["jest-serializer-enzyme"] + }, "dependencies": { "axios": "0.16.1", "babel-plugin-dynamic-import-webpack": "1.0.1",