-
-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEXT: Resolve Unit Tests - Part 2 (#2814)
- Loading branch information
1 parent
91d040e
commit 8735a49
Showing
8 changed files
with
348 additions
and
274 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@skeletonlabs/skeleton-react": patch | ||
--- | ||
|
||
Resolved regressions in the following test cases: progress ring, ratings, segment control, switch, and tabs |
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
54 changes: 54 additions & 0 deletions
54
packages/skeleton-react/src/lib/components/Rating/Rating.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,54 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { render } from '@testing-library/react'; | ||
|
||
import { Rating } from './Rating.js'; | ||
|
||
describe('<Rating>', () => { | ||
it('should render the component', () => { | ||
const { getByTestId } = render(<Rating />); | ||
const component = getByTestId('rating'); | ||
expect(component).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render with a value', () => { | ||
const testValue = 14; | ||
const { getByTestId } = render(<Rating value={testValue} />); | ||
const input = getByTestId('rating-input'); | ||
expect(input.getAttribute('value')).eq(`${testValue}`); | ||
}); | ||
|
||
it('should render with custom iconEmpty', () => { | ||
const testIconEmpty = 'testIconEmpty'; | ||
const { getAllByTestId } = render(<Rating value={0} iconEmpty={testIconEmpty} />); | ||
const elementIcons = getAllByTestId('rating-item'); | ||
expect(elementIcons[0]).toHaveTextContent(testIconEmpty); | ||
}); | ||
|
||
it('should render with custom iconHalf', () => { | ||
const testIconHalf = 'testIconHalf'; | ||
const { getAllByTestId } = render(<Rating value={0.5} iconHalf={testIconHalf} allowHalf />); | ||
const elementIcons = getAllByTestId('rating-item'); | ||
expect(elementIcons[0]).toHaveTextContent(testIconHalf); | ||
}); | ||
|
||
it('should render with custom iconFull', () => { | ||
const testIconFull = 'testIconFull'; | ||
const { getAllByTestId } = render(<Rating value={1} iconFull={testIconFull} />); | ||
const elementIcons = getAllByTestId('rating-item'); | ||
expect(elementIcons[0]).toHaveTextContent(testIconFull); | ||
}); | ||
|
||
it('should render base classes on root', () => { | ||
const testClass = 'bg-green-500'; | ||
const { getByTestId } = render(<Rating base={testClass} />); | ||
const component = getByTestId('rating'); | ||
expect(component).toHaveClass(testClass); | ||
}); | ||
|
||
it('should render arbitrary classes on root', () => { | ||
const testClass = 'bg-green-500'; | ||
const { getByTestId } = render(<Rating classes={testClass} />); | ||
const component = getByTestId('rating'); | ||
expect(component).toHaveClass(testClass); | ||
}); | ||
}); |
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
Oops, something went wrong.