-
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.
fix (#273): update Labal unit test after merging develop
- Loading branch information
1 parent
f79a31c
commit 5e155f8
Showing
2 changed files
with
13 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,40 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { Label } from './Label'; | ||
import { labelVariants } from './labelVariants'; | ||
|
||
const variantClasses = { | ||
default: 'text-sm text-zinc-300 cursor-text flex-col gap-1.5', | ||
secondary: 'text-zinc-50 cursor-pointer rounded-xl items-center py-4 px-3 border-2 border-zinc-800 peer-aria-checked:border-orange-600 peer-hover:bg-zinc-800 flex', | ||
}; | ||
|
||
describe('Label', () => { | ||
labelVariants.forEach((variant) => { | ||
it(`renders correctly with variant ${variant}`, () => { | ||
const disabledVariants = [true, false]; | ||
|
||
disabledVariants.forEach((disabled) => { | ||
it(`renders correctly when disabled is ${disabled}`, () => { | ||
render( | ||
<Label data-testid="test-label" variant={variant}> | ||
<Label data-testid="test-label" disabled={disabled}> | ||
Test Label | ||
</Label> | ||
); | ||
|
||
const label = screen.getByTestId('test-label'); | ||
expect(label).toBeInTheDocument(); | ||
if (variant) { | ||
expect(label).toHaveClass(variantClasses[variant]); | ||
} | ||
|
||
const expectedClass = disabled ? 'opacity-50 cursor-not-allowed' : 'peer-aria-checked:border-accent peer-hover:border-white'; | ||
expect(label).toHaveClass(expectedClass); | ||
}); | ||
}); | ||
|
||
it(`applies additional custom classes correctly`, () => { | ||
it('applies additional custom classes correctly', () => { | ||
const extraClasses = 'custom-class-label extra-custom-class'; | ||
render( | ||
<Label | ||
data-testid="custom-class-label" | ||
className="custom-class-label extra-custom-class" | ||
className={extraClasses} | ||
> | ||
Custom Test Label | ||
</Label> | ||
); | ||
|
||
const labelCustom = screen.getByTestId('custom-class-label'); | ||
expect(labelCustom).toBeInTheDocument(); | ||
if (labelCustom.hasAttribute('className')) { | ||
expect(labelCustom).toHaveClass('custom-class-label extra-custom-class'); | ||
} | ||
expect(labelCustom).toHaveClass(extraClasses); | ||
}); | ||
}); | ||
|
This file was deleted.
Oops, something went wrong.