Selaa lähdekoodia

upgrade enzyme

afc163 8 vuotta sitten
vanhempi
commit
12f41ad836
4 muutettua tiedostoa jossa 10 lisäystä ja 2 poistoa
  1. 1 0
      .eslintrc
  2. 2 1
      package.json
  3. 3 1
      src/routes/Dashboard.test.js
  4. 4 0
      tests/setupTests.js

+ 1 - 0
.eslintrc

@@ -6,6 +6,7 @@
     "node": true,
     "es6": true,
     "mocha": true,
+    "jest": true,
     "jasmine": true
   },
   "rules": {

+ 2 - 1
package.json

@@ -33,7 +33,8 @@
     "babel-plugin-transform-runtime": "^6.9.0",
     "babel-runtime": "^6.9.2",
     "cross-port-killer": "^1.0.1",
-    "enzyme": "^2.9.1",
+    "enzyme": "^3.1.0",
+    "enzyme-adapter-react-15": "^1.0.2",
     "eslint": "^4.8.0",
     "eslint-config-airbnb": "^16.0.0",
     "eslint-plugin-babel": "^4.0.0",

+ 3 - 1
src/routes/Dashboard.test.js

@@ -3,8 +3,10 @@ import { shallow } from 'enzyme';
 import Dashboard from './Dashboard';
 
 it('renders Dashboard', () => {
+  const fetchFn = jest.fn();
   const wrapper = shallow(
-    <Dashboard.WrappedComponent user={{ list: [] }} />
+    <Dashboard.WrappedComponent user={{ list: [] }} dispatch={fetchFn} />
   );
   expect(wrapper.find('Table').props().dataSource).toEqual([]);
+  expect(fetchFn).toBeCalled();
 });

+ 4 - 0
tests/setupTests.js

@@ -1,4 +1,8 @@
 import { jsdom } from 'jsdom';
+import Enzyme from 'enzyme';
+import Adapter from 'enzyme-adapter-react-15';
+
+Enzyme.configure({ adapter: new Adapter() });
 
 // fixed jsdom miss
 const documentHTML = '<!doctype html><html><body><div id="root"></div></body></html>';