forked from mui/material-ui
/
Sheet.test.js
62 lines (52 loc) · 1.91 KB
/
Sheet.test.js
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import * as React from 'react';
import { expect } from 'chai';
import { createRenderer, describeConformance } from 'test/utils';
import { ThemeProvider } from '@mui/joy/styles';
import Sheet, { sheetClasses as classes } from '@mui/joy/Sheet';
import { unstable_capitalize as capitalize } from '@mui/utils';
describe('<Sheet />', () => {
const { render } = createRenderer();
describeConformance(<Sheet />, () => ({
classes,
inheritComponent: 'div',
render,
ThemeProvider,
muiName: 'JoySheet',
refInstanceof: window.HTMLDivElement,
testComponentPropWith: 'header',
testVariantProps: { variant: 'solid' },
skip: ['classesRoot', 'componentsProp'],
}));
describe('prop: variant', () => {
it('plain by default', () => {
const { getByTestId } = render(<Sheet data-testid="root">Hello World</Sheet>);
expect(getByTestId('root')).to.have.class(classes.variantPlain);
});
['plain', 'outlined', 'soft', 'solid'].forEach((variant) => {
it(`should render ${variant}`, () => {
const { getByTestId } = render(
<Sheet data-testid="root" variant={variant}>
Hello World
</Sheet>,
);
expect(getByTestId('root')).to.have.class(classes[`variant${capitalize(variant)}`]);
});
});
});
describe('prop: color', () => {
it('adds a neutral class by default', () => {
const { getByTestId } = render(<Sheet data-testid="root">Hello World</Sheet>);
expect(getByTestId('root')).to.have.class(classes.colorNeutral);
});
['primary', 'success', 'info', 'danger', 'neutral', 'warning'].forEach((color) => {
it(`should render ${color}`, () => {
const { getByTestId } = render(
<Sheet data-testid="root" color={color}>
Hello World
</Sheet>,
);
expect(getByTestId('root')).to.have.class(classes[`color${capitalize(color)}`]);
});
});
});
});