Skip to content

Commit 40ca5d8

Browse files
authored
add snap (#228)
* add value prop * add value prop * add value prop * add value prop * add snap
1 parent ac97e7e commit 40ca5d8

File tree

4 files changed

+67
-5
lines changed

4 files changed

+67
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ lib
2929
es
3030
coverage
3131
yarn.lock
32+
package-lock.json
3233

3334

3435
# dumi

src/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import classNames from 'classnames';
2+
import useMergedState from 'rc-util/lib/hooks/useMergedState';
13
import * as React from 'react';
24
import { forwardRef, useImperativeHandle, useRef } from 'react';
3-
import useMergedState from 'rc-util/lib/hooks/useMergedState';
4-
import classNames from 'classnames';
55

66
export interface CheckboxChangeEvent {
77
target: CheckboxChangeEventTarget;
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`rc-checkbox click checkbox 1`] = `
4+
<span
5+
class="rc-checkbox"
6+
>
7+
<input
8+
class="rc-checkbox-input"
9+
type="checkbox"
10+
/>
11+
<span
12+
class="rc-checkbox-inner"
13+
/>
14+
</span>
15+
`;
16+
17+
exports[`rc-checkbox click radio 1`] = `
18+
<span
19+
class="rc-checkbox rc-checkbox-checked"
20+
>
21+
<input
22+
class="rc-checkbox-input"
23+
type="radio"
24+
/>
25+
<span
26+
class="rc-checkbox-inner"
27+
/>
28+
</span>
29+
`;
30+
31+
exports[`rc-checkbox control mode 1`] = `
32+
<span
33+
class="rc-checkbox rc-checkbox-checked"
34+
>
35+
<input
36+
checked=""
37+
class="rc-checkbox-input"
38+
type="checkbox"
39+
/>
40+
<span
41+
class="rc-checkbox-inner"
42+
/>
43+
</span>
44+
`;
45+
46+
exports[`rc-checkbox works 1`] = `
47+
<span
48+
class="rc-checkbox"
49+
>
50+
<input
51+
class="rc-checkbox-input"
52+
type="checkbox"
53+
/>
54+
<span
55+
class="rc-checkbox-inner"
56+
/>
57+
</span>
58+
`;

tests/index.test.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as React from 'react';
2-
import KeyCode from 'rc-util/lib/KeyCode';
31
import { fireEvent, render } from '@testing-library/react';
2+
import KeyCode from 'rc-util/lib/KeyCode';
3+
import * as React from 'react';
44
import Checkbox from '../src';
55

66
import type { CheckboxRef } from '../src';
@@ -17,6 +17,7 @@ describe('rc-checkbox', () => {
1717

1818
fireEvent.click(inputEl);
1919
expect(inputEl.checked).toBe(false);
20+
expect(container.firstChild).toMatchSnapshot();
2021
});
2122

2223
it('click radio', () => {
@@ -30,6 +31,7 @@ describe('rc-checkbox', () => {
3031

3132
fireEvent.click(inputEl);
3233
expect(inputEl.checked).toBe(true);
34+
expect(container.firstChild).toMatchSnapshot();
3335
});
3436

3537
it('click checkbox', () => {
@@ -43,6 +45,7 @@ describe('rc-checkbox', () => {
4345

4446
fireEvent.click(inputEl);
4547
expect(inputEl.checked).toBe(false);
48+
expect(container.firstChild).toMatchSnapshot();
4649
});
4750

4851
it('control mode', () => {
@@ -56,6 +59,7 @@ describe('rc-checkbox', () => {
5659

5760
fireEvent.click(inputEl);
5861
expect(inputEl.checked).toBe(true);
62+
expect(container.firstChild).toMatchSnapshot();
5963
});
6064

6165
it('stopPropagation and preventDefault', () => {
@@ -93,7 +97,6 @@ describe('rc-checkbox', () => {
9397
});
9498

9599
it('passes role prop to input', () => {
96-
// eslint-disable-next-line jsx-a11y/aria-role
97100
const { container } = render(<Checkbox role="my-role" />);
98101
const inputEl = container.querySelector('input')!;
99102

0 commit comments

Comments
 (0)