Skip to content

Commit

Permalink
Add SideLabel story
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadiuszbachorski committed Oct 15, 2024
1 parent cf2f0b7 commit fa3d99c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions packages/design-system/src/components/SideLabel/SideLabel.test.tsx
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')
})
})

0 comments on commit fa3d99c

Please sign in to comment.