generated from StanfordBDHG/NextJSTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
cf2f0b7
commit fa3d99c
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
packages/design-system/src/components/SideLabel/SideLabel.test.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,30 @@ | ||
// | ||
// This source file is part of the Stanford Biodesign Digital Health ENGAGE-HF open-source project | ||
// | ||
// SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
import { fireEvent, render, screen } from '@testing-library/react' | ||
import { vitest } from 'vitest' | ||
import { SideLabel } from '.' | ||
|
||
describe('SideLabel', () => { | ||
it('renders functional label element', () => { | ||
const onChange = vitest.fn() | ||
|
||
render( | ||
<SideLabel label="Toggle"> | ||
<input type="checkbox" onChange={onChange} /> | ||
</SideLabel>, | ||
) | ||
|
||
const textElement = screen.getByText('Toggle') | ||
fireEvent.click(textElement) | ||
|
||
expect(onChange).toHaveBeenCalledOnce() | ||
|
||
const element = screen.getByLabelText('Toggle') | ||
expect(element.tagName).toBe('INPUT') | ||
}) | ||
}) |