-
Notifications
You must be signed in to change notification settings - Fork 161
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
44f8515
commit 24d3255
Showing
5 changed files
with
324 additions
and
93 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 @@ | ||
--- | ||
"@rocket.chat/fuselage": minor | ||
--- | ||
|
||
feat(fuselage): `Callout` visual changes |
60 changes: 22 additions & 38 deletions
60
packages/fuselage/src/components/Callout/Callout.spec.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 |
---|---|---|
@@ -1,47 +1,31 @@ | ||
import { composeStories } from '@storybook/testing-react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { render } from '@testing-library/react'; | ||
import { axe } from 'jest-axe'; | ||
import React from 'react'; | ||
|
||
import { Callout } from './Callout'; | ||
import * as stories from './Callout.stories'; | ||
|
||
const { Default, WithDescriptionOnly, Info, Success, Warning, Danger } = | ||
composeStories(stories); | ||
const testCases = Object.values(composeStories(stories)).map((Story) => [ | ||
Story.storyName || 'Story', | ||
Story, | ||
]); | ||
|
||
describe('[Callout Component]', () => { | ||
describe('Storybook', () => { | ||
it.each([ | ||
['Default', Default], | ||
['WithDescriptionOnly', WithDescriptionOnly], | ||
['Info', Info], | ||
['Success', Success], | ||
['Warning', Warning], | ||
['Danger', Danger], | ||
])('renders %p story without crashing', (_storyName, Story) => { | ||
render(<Story />); | ||
}); | ||
describe('[CheckBox Rendering]', () => { | ||
test.each(testCases)( | ||
`renders %s without crashing`, | ||
async (_storyname, Story) => { | ||
const tree = render(<Story />); | ||
expect(tree.baseElement).toMatchSnapshot(); | ||
} | ||
); | ||
|
||
it.each([ | ||
['.rcx-callout--type-info', 'info', Info], | ||
['.rcx-callout--type-success', 'success', Success], | ||
['.rcx-callout--type-warning', 'warning', Warning], | ||
['.rcx-callout--type-danger', 'danger', Danger], | ||
])( | ||
'should have class %p when type is %p', | ||
(className, _typeName, Story) => { | ||
const { container } = render(<Story />); | ||
expect(container.querySelector(className)).toBeInTheDocument(); | ||
} | ||
); | ||
}); | ||
test.each(testCases)( | ||
'%s should have no a11y violations', | ||
async (_storyname, Story) => { | ||
const { container } = render(<Story />); | ||
|
||
it('should show title when this property is passed', () => { | ||
render(<Callout title='test-title' />); | ||
screen.getByText('test-title'); | ||
}); | ||
|
||
it('should display children', () => { | ||
render(<Callout>Children</Callout>); | ||
screen.getByText('Children'); | ||
}); | ||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
} | ||
); | ||
}); |
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.