Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

Change the way we test snapshots #1273

Merged
merged 2 commits into from
Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/components/Details/__tests__/DetailObject.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Icon } from 'patternfly-react';
import { default as DetailObject } from '../DetailObject';
import { PfColors } from '../../Pf/PfColors';
import { DestinationWeight } from '../../../types/IstioObjects';
import { shallowToJson } from 'enzyme-to-json';

describe('DetailObject test', () => {
const detail: DestinationWeight = {
Expand All @@ -29,8 +30,8 @@ describe('DetailObject test', () => {

const wrapper = shallow(<DetailObject name={name} detail={detail} />);

expect(wrapper).toBeDefined();
expect(wrapper).toMatchSnapshot();
expect(shallowToJson(wrapper)).toBeDefined();
expect(shallowToJson(wrapper)).toMatchSnapshot();

expect(wrapper.html()).toContain('<span class="text-capitalize">[host]</span>');
expect(wrapper.html()).toContain('<span class="text-capitalize">[subset]</span>');
Expand All @@ -46,8 +47,8 @@ describe('DetailObject test', () => {

const wrapper = shallow(<DetailObject name={name} detail={detail} exclude={['port']} />);

expect(wrapper).toBeDefined();
expect(wrapper).toMatchSnapshot();
expect(shallowToJson(wrapper)).toBeDefined();
expect(shallowToJson(wrapper)).toMatchSnapshot();

expect(wrapper.html()).toContain('<span class="text-capitalize">[host]</span>');
expect(wrapper.html()).toContain('<span class="text-capitalize">[subset]</span>');
Expand All @@ -69,8 +70,8 @@ describe('DetailObject test', () => {

const wrapper = shallow(<DetailObject name={name} detail={detail} validation={validation} />);

expect(wrapper).toBeDefined();
expect(wrapper).toMatchSnapshot();
expect(shallowToJson(wrapper)).toBeDefined();
expect(shallowToJson(wrapper)).toMatchSnapshot();

const iconWrapper = wrapper.find(Icon);
expect(iconWrapper.prop('type')).toEqual('pf');
Expand All @@ -89,8 +90,8 @@ describe('DetailObject test', () => {

const wrapper = shallow(<DetailObject name={name} detail={detail} validation={validation} />);

expect(wrapper).toBeDefined();
expect(wrapper).toMatchSnapshot();
expect(shallowToJson(wrapper)).toBeDefined();
expect(shallowToJson(wrapper)).toMatchSnapshot();

const iconWrapper = wrapper.find(Icon);
expect(iconWrapper.length).toEqual(0);
Expand Down
Loading