Skip to content

Commit

Permalink
Add unit test using full rendering
Browse files Browse the repository at this point in the history
  It processes all the descendent components.

  Issue: enzyme is not yet compatible with React 17
  ref: enzymejs/enzyme#2462

  How to check the React version on the project
  The package.json contains `"react": "^17.0.1",`
  ref: https://www.positronx.io/how-to-check-react-app-version-quickly/
  • Loading branch information
llama90 committed Dec 25, 2020
1 parent 7eaa18d commit ef8da12
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions react/testapp/src/test/appContent.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import Adapter from 'enzyme-adapter-react-16';
import Enzyme, {shallow} from "enzyme";
import Enzyme, {shallow, mount} from "enzyme";
import App from "../App";
import {ValueInput} from "../component/ValueInput";

Expand All @@ -10,4 +10,16 @@ it("Renders three ValueInputs", () => {
const wrapper = shallow(<App/>);
const valCount = wrapper.find(ValueInput).length;
expect(valCount).toBe(3)
});
});

it("Fully renders three inputs", () => {
const wrapper = mount(<App title="tester"/>);
const count = wrapper.find("input.form-control").length;
expect(count).toBe(3);
});

it("Shallow renders zero inputs", () => {
const wrapper = shallow(<App/>);
const count = wrapper.find("input.form-control").length;
expect(count).toBe(0);
})

0 comments on commit ef8da12

Please sign in to comment.