-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathPrimaryButton.test.tsx
More file actions
39 lines (31 loc) · 1.25 KB
/
PrimaryButton.test.tsx
File metadata and controls
39 lines (31 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import AddIcon from '@mui/icons-material/Add';
import { render } from 'test-helpers/test-utils';
import { PrimaryButton } from './PrimaryButton';
describe('PrimaryButton', () => {
it('applies primary defaults', () => {
const { getByRole } = render(<PrimaryButton>Create</PrimaryButton>);
const button = getByRole('button', { name: 'Create' });
expect(button.className).toContain('MuiButton-contained');
expect(button.className).toContain('MuiButton-containedPrimary');
expect(button.className).toContain('MuiButton-sizeMedium');
});
it('allows overriding defaults', () => {
const { getByRole } = render(
<PrimaryButton variant="text" size="small">
Create
</PrimaryButton>
);
const button = getByRole('button', { name: 'Create' });
expect(button.className).toContain('MuiButton-text');
expect(button.className).toContain('MuiButton-sizeSmall');
});
it('renders start and end icons', () => {
const { getByTestId } = render(
<PrimaryButton startIcon={<AddIcon data-testid="start-icon" />} endIcon={<AddIcon data-testid="end-icon" />}>
Create
</PrimaryButton>
);
expect(getByTestId('start-icon')).toBeVisible();
expect(getByTestId('end-icon')).toBeVisible();
});
});