-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Riley Pearce
committed
Feb 8, 2024
1 parent
0cd20b4
commit 58de0b3
Showing
7 changed files
with
64 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
packages/@mantine-tests/core/src/inputs/it-handles-checkbox-state.tsx
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
packages/@mantine-tests/core/src/inputs/it-handles-switch-checkbox-state.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
import { screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { render } from '../render'; | ||
|
||
interface Options<Props = any> { | ||
component: React.ComponentType<Props>; | ||
props: Props; | ||
} | ||
|
||
export function itHandlesSwitchCheckboxState<Props>( | ||
options: Options<Props>, | ||
name = 'handles switch checkbox state' | ||
) { | ||
describe(name, () => { | ||
it('correctly handles controlled switch checkbox state', async () => { | ||
const spy = jest.fn(); | ||
render(<options.component {...options.props} checked={false} onChange={spy} />); | ||
expect(screen.getByRole('switch')).not.toBeChecked(); | ||
await userEvent.click(screen.getByRole('switch')); | ||
expect(spy).toHaveBeenCalledTimes(1); | ||
expect(screen.getByRole('switch')).not.toBeChecked(); | ||
}); | ||
|
||
it('correctly handles uncontrolled switch checkbox state', async () => { | ||
render(<options.component {...options.props} defaultChecked={false} />); | ||
expect(screen.getByRole('switch')).not.toBeChecked(); | ||
await userEvent.click(screen.getByRole('switch')); | ||
expect(screen.getByRole('switch')).toBeChecked(); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters