Skip to content

Commit

Permalink
update snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiantela committed May 11, 2023
1 parent 053f65f commit fbe7e5d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,21 @@ exports[`SendMsgForm render should render 1`] = `
"name": "Attachments",
},
Object {
"body": <CheckboxElement
checked={false}
description="Send a message to all destinations known for this contact. If you aren't sure what this means, leave it unchecked."
labelClassName="checkbox"
name="All Destinations"
onChange={[Function]}
title="All Destinations"
/>,
"body": <React.Fragment>
<div
className="u font secondary body-md color-neutral-cloudy title"
>
Send a message to all destinations known for this contact.
</div>
<SwitchElement
checked={false}
description="If you aren't sure what this means, leave it unchecked."
name="Send a message to all destinations"
onChange={[Function]}
size="small"
title="Send a message to all destinations"
/>
</React.Fragment>,
"checked": false,
"name": "Advanced",
},
Expand Down
39 changes: 4 additions & 35 deletions src/components/form/switch/SwitchElement.test.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
import { composeComponentTestUtils, getSpecWrapper } from 'testUtils';

import SwitchElement, {
boxIco,
SwitchElementProps,
switchSpecId,
checkedBoxIco,
descSpecId,
titleSpecId
} from './SwitchElement';
import SwitchElement, { SwitchElementProps, descSpecId } from './SwitchElement';

const baseProps: SwitchElementProps = {
name: 'Switch',
checked: false
};

const { setup, spyOn } = composeComponentTestUtils(SwitchElement, baseProps);
const { setup } = composeComponentTestUtils(SwitchElement, baseProps);

describe(SwitchElement.name, () => {
it('should render a switch element with title, description', () => {
const setStateSpy = spyOn('setState');
const { wrapper, props } = setup(true, {
it('should render a switch element with description', () => {
const { wrapper } = setup(true, {
$merge: {
title: 'Switch',
description: 'All Destinations',
Expand All @@ -29,30 +21,7 @@ describe(SwitchElement.name, () => {
}
});

expect(getSpecWrapper(wrapper, switchSpecId).hasClass(boxIco)).toBeTruthy();
expect(getSpecWrapper(wrapper, titleSpecId).exists()).toBeTruthy();
expect(getSpecWrapper(wrapper, descSpecId).hasClass('description')).toBeTruthy();
expect(wrapper).toMatchSnapshot('unchecked');

// Check box
wrapper.find('label').prop('onClick')();
wrapper.update();

expect(setStateSpy).toHaveBeenCalledTimes(1);
expect(setStateSpy).toMatchCallSnapshot();
expect(props.onChange).toHaveBeenCalledTimes(1);
expect(getSpecWrapper(wrapper, switchSpecId).hasClass(checkedBoxIco)).toBeTruthy();
expect(wrapper).toMatchSnapshot();

// Remove title
wrapper.setProps({
title: '',
description: 'Continue when there is no response'
});

expect(getSpecWrapper(wrapper, descSpecId).hasClass('description_solo')).toBeTruthy();
expect(wrapper).toMatchSnapshot();

setStateSpy.mockRestore();
});
});
83 changes: 13 additions & 70 deletions src/components/form/switch/__snapshots__/SwitchElement.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,79 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`CheckboxElement should render a checkbox element with title, description 1`] = `
Array [
Object {
"checked": true,
},
]
`;

exports[`CheckboxElement should render a checkbox element with title, description 2`] = `
<label
className="label label"
onClick={[Function]}
>
<span
className="fe-check-square checkbox"
data-spec="checkbox"
/>
<div
className="title"
data-spec="title"
>
Checkbox
</div>
<div
className="description"
data-spec="description"
>
All Destinations
</div>
</label>
`;

exports[`CheckboxElement should render a checkbox element with title, description 3`] = `
<label
className="label label"
onClick={[Function]}
>
<span
className="fe-check-square checkbox"
data-spec="checkbox"
exports[`SwitchElement should render a switch element with description: unchecked 1`] = `
<Fragment>
<ForwardRef
data-spec="switch"
on={
Object {
"input": [Function],
}
}
textRight="Switch"
value={false}
/>
<div
className="title"
data-spec="title"
/>
<div
className="description_solo"
data-spec="description"
>
Continue when there is no response
</div>
</label>
`;

exports[`CheckboxElement should render a checkbox element with title, description: unchecked 1`] = `
<label
className="label label"
onClick={[Function]}
>
<span
className="fe-square checkbox"
data-spec="checkbox"
/>
<div
className="title"
data-spec="title"
>
Checkbox
</div>
<div
className="description"
className="u font secondary body-sm color-neutral-cloudy description"
data-spec="description"
>
All Destinations
</div>
</label>
</Fragment>
`;

0 comments on commit fbe7e5d

Please sign in to comment.