fix(tests): use diffable html instead tree snapshots

This commit is contained in:
Łukasz Mierzwa
2018-09-02 18:14:00 +01:00
parent 2ee69f9c08
commit 5e0c766f44
2 changed files with 281 additions and 953 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -2,6 +2,8 @@ import React from "react";
import { shallow, mount } from "enzyme";
import toDiffableHtml from "diffable-html";
import { MultiSelect } from ".";
const Option = value => ({ label: value, value: value });
@@ -25,19 +27,19 @@ class CustomMultiSelect extends MultiSelect {
describe("<CustomMultiSelect />", () => {
it("matches snapshot with defaults", () => {
const tree = shallow(<CustomMultiSelect />);
expect(tree).toMatchSnapshot();
expect(toDiffableHtml(tree.html())).toMatchSnapshot();
});
it("matches snapshot with isMulti=true", () => {
const tree = shallow(<CustomMultiSelect isMulti />);
expect(tree).toMatchSnapshot();
expect(toDiffableHtml(tree.html())).toMatchSnapshot();
});
it("matches snapshot when focused", () => {
// this test is to cover styles state.isFocused conditions
const tree = mount(<CustomMultiSelect autoFocus />);
tree.find("input").simulate("focus");
expect(tree).toMatchSnapshot();
expect(toDiffableHtml(tree.html())).toMatchSnapshot();
});
it("matches snapshot with a value", () => {
@@ -47,7 +49,7 @@ describe("<CustomMultiSelect />", () => {
options={[Option("foo", Option("bar"))]}
/>
);
expect(tree).toMatchSnapshot();
expect(toDiffableHtml(tree.html())).toMatchSnapshot();
});
it("matches snapshot with isMulti=true and a value", () => {
@@ -58,6 +60,6 @@ describe("<CustomMultiSelect />", () => {
options={[Option("foo", Option("bar"))]}
/>
);
expect(tree).toMatchSnapshot();
expect(toDiffableHtml(tree.html())).toMatchSnapshot();
});
});