Browse Source

shallow() options. Coding standards.

Frederic G. MARAND 6 years ago
parent
commit
c6a6a9e71c
5 changed files with 24 additions and 12 deletions
  1. 1 0
      .eslintignore
  2. 1 1
      .eslintrc.js
  3. 6 0
      .idea/vcs.xml
  4. 10 5
      src/App.test.js
  5. 6 6
      src/index.js

+ 1 - 0
.eslintignore

@@ -0,0 +1 @@
+src/registerServiceWorker.js

+ 1 - 1
.eslintrc.js

@@ -57,7 +57,7 @@ module.exports = {
     //
     // The following rules point out areas where you might have made mistakes.
     //
-    "comma-dangle": 2, // disallow or enforce trailing commas
+    "comma-dangle": [2, "only-multiline"], // disallow or enforce trailing commas
     "no-cond-assign": 2, // disallow assignment in conditional expressions
     "no-console": 1, // disallow use of console (off by default in the node environment)
     "no-constant-condition": 2, // disallow use of constant expressions in conditions

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>

+ 10 - 5
src/App.test.js

@@ -1,17 +1,22 @@
 import "raf/polyfill";
 import React from "react";
-import ReactDOM from "react-dom";
 import App from "./App";
-import { configure, shallow } from 'enzyme';
-import Adapter from 'enzyme-adapter-react-16';
+import { configure, shallow } from "enzyme";
+import Adapter from "enzyme-adapter-react-16";
 
 // Configure Enzyme for the React version we're using.
 // Could be in a test setup file. Required for React 16, 15, 0.14, 0.13.
-configure({ adapter: new Adapter });
+configure({ adapter: new Adapter() });
 
 describe("<App />>", () => {
   it("should render App", () => {
-    const wrapper = shallow(<App />);
+    const wrapper = shallow(<App />, {
+      // Pass a context to component.
+      context: {},
+      // Disable component mount lifecycle methods, as well as update after
+      // setProps() and setContext().
+      disableLifecycleMethods: true,
+    });
     console.log(wrapper.debug());
   });
 });

+ 6 - 6
src/index.js

@@ -1,8 +1,8 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
-import './index.css';
-import App from './App';
-import registerServiceWorker from './registerServiceWorker';
+import React from "react";
+import ReactDOM from "react-dom";
+import "./index.css";
+import App from "./App";
+import registerServiceWorker from "./registerServiceWorker";
 
-ReactDOM.render(<App />, document.getElementById('root'));
+ReactDOM.render(<App />, document.getElementById("root"));
 registerServiceWorker();