diff --git a/.gitignore b/.gitignore index 3fa2c9b..0b37a42 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ lib es coverage yarn.lock +package-lock.json # dumi diff --git a/src/index.tsx b/src/index.tsx index bf7492c..b047186 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,7 +1,7 @@ +import classNames from 'classnames'; +import useMergedState from 'rc-util/lib/hooks/useMergedState'; import * as React from 'react'; import { forwardRef, useImperativeHandle, useRef } from 'react'; -import useMergedState from 'rc-util/lib/hooks/useMergedState'; -import classNames from 'classnames'; export interface CheckboxChangeEvent { target: CheckboxChangeEventTarget; diff --git a/tests/__snapshots__/index.test.tsx.snap b/tests/__snapshots__/index.test.tsx.snap new file mode 100644 index 0000000..07c12b0 --- /dev/null +++ b/tests/__snapshots__/index.test.tsx.snap @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`rc-checkbox click checkbox 1`] = ` + + + + +`; + +exports[`rc-checkbox click radio 1`] = ` + + + + +`; + +exports[`rc-checkbox control mode 1`] = ` + + + + +`; + +exports[`rc-checkbox works 1`] = ` + + + + +`; diff --git a/tests/index.test.tsx b/tests/index.test.tsx index ce49697..7f5fc19 100644 --- a/tests/index.test.tsx +++ b/tests/index.test.tsx @@ -1,6 +1,6 @@ -import * as React from 'react'; -import KeyCode from 'rc-util/lib/KeyCode'; import { fireEvent, render } from '@testing-library/react'; +import KeyCode from 'rc-util/lib/KeyCode'; +import * as React from 'react'; import Checkbox from '../src'; import type { CheckboxRef } from '../src'; @@ -17,6 +17,7 @@ describe('rc-checkbox', () => { fireEvent.click(inputEl); expect(inputEl.checked).toBe(false); + expect(container.firstChild).toMatchSnapshot(); }); it('click radio', () => { @@ -30,6 +31,7 @@ describe('rc-checkbox', () => { fireEvent.click(inputEl); expect(inputEl.checked).toBe(true); + expect(container.firstChild).toMatchSnapshot(); }); it('click checkbox', () => { @@ -43,6 +45,7 @@ describe('rc-checkbox', () => { fireEvent.click(inputEl); expect(inputEl.checked).toBe(false); + expect(container.firstChild).toMatchSnapshot(); }); it('control mode', () => { @@ -56,6 +59,7 @@ describe('rc-checkbox', () => { fireEvent.click(inputEl); expect(inputEl.checked).toBe(true); + expect(container.firstChild).toMatchSnapshot(); }); it('stopPropagation and preventDefault', () => { @@ -93,7 +97,6 @@ describe('rc-checkbox', () => { }); it('passes role prop to input', () => { - // eslint-disable-next-line jsx-a11y/aria-role const { container } = render(); const inputEl = container.querySelector('input')!;