Skip to content

Commit dd2cb51

Browse files
Mario Aguiarravichdev
authored andcommitted
Add switch snapshot
1 parent cbb8854 commit dd2cb51

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Settings: Switch matches snapshot 1`] = `
4+
<div>
5+
<div
6+
class="material-settings__switch"
7+
>
8+
<div
9+
class="mdc-switch material-wizard-switch mdc-switch--checked"
10+
>
11+
<div
12+
class="mdc-switch__track"
13+
/>
14+
<div
15+
class="mdc-switch__thumb-underlay"
16+
>
17+
<div
18+
class="mdc-switch__thumb"
19+
/>
20+
<input
21+
aria-checked="true"
22+
checked=""
23+
class="mdc-switch__native-control"
24+
id="material-settings__switch"
25+
role="switch"
26+
type="checkbox"
27+
/>
28+
</div>
29+
</div>
30+
<label
31+
for="material-settings__switch"
32+
id="label-material-settings__switch"
33+
>
34+
Auto-updates enabled
35+
</label>
36+
</div>
37+
</div>
38+
`;
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* Copyright 2020 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* External dependencies
19+
*/
20+
import { mount } from 'enzyme';
21+
import '@testing-library/jest-dom/extend-expect';
22+
import { render } from '@testing-library/react';
23+
24+
/**
25+
* Internal dependencies
26+
*/
27+
import Switch from '../../../../../assets/src/settings/components/integrations/switch';
28+
import { SettingsProvider } from '../../../../../assets/src/settings/context';
29+
30+
const setup = props => {
31+
return render(
32+
<SettingsProvider>
33+
<Switch { ...props } />
34+
</SettingsProvider>
35+
);
36+
};
37+
38+
const baseProps = {
39+
id: 'material-settings__switch',
40+
checked: true,
41+
onChange: jest.fn(),
42+
};
43+
44+
describe( 'Settings: Switch', () => {
45+
const wrapper = mount(
46+
<SettingsProvider>
47+
<Switch { ...baseProps } />
48+
</SettingsProvider>
49+
);
50+
51+
beforeEach( () => {
52+
baseProps.onChange.mockClear();
53+
} );
54+
55+
it( 'matches snapshot', () => {
56+
const { container } = setup( baseProps );
57+
expect( container ).toMatchSnapshot();
58+
} );
59+
60+
it( 'should be checked', () => {
61+
const isChecked = wrapper.find( '.mdc-switch__native-control' );
62+
63+
expect( isChecked.props() ).toHaveProperty( 'aria-checked', true );
64+
} );
65+
} );

0 commit comments

Comments
 (0)