-
-
Notifications
You must be signed in to change notification settings - Fork 213
Expand file tree
/
Copy pathGroupBox.spec.tsx
More file actions
53 lines (46 loc) · 1.76 KB
/
Copy pathGroupBox.spec.tsx
File metadata and controls
53 lines (46 loc) · 1.76 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import React from 'react';
import { renderWithTheme, theme } from '../../test/utils';
import { GroupBox } from './GroupBox';
describe('<GroupBox />', () => {
it('renders GroupBox', () => {
const { container } = renderWithTheme(<GroupBox />);
const groupBox = container.firstChild as HTMLFieldSetElement;
expect(groupBox).toBeInTheDocument();
});
it('renders children', () => {
const textContent = 'Hi there!';
const { getByText } = renderWithTheme(
<GroupBox>
<span>{textContent}</span>
</GroupBox>
);
expect(getByText(textContent)).toBeInTheDocument();
});
describe('prop: label', () => {
it('renders Label', () => {
const labelText = 'Name:';
const { container } = renderWithTheme(<GroupBox label={labelText} />);
const groupBox = container.firstChild as HTMLFieldSetElement;
const legend = groupBox.querySelector('legend');
expect(legend?.textContent).toBe(labelText);
});
it('when not provided, <legend /> element is not rendered', () => {
const { container } = renderWithTheme(<GroupBox />);
const groupBox = container.firstChild as HTMLFieldSetElement;
const legend = groupBox.querySelector('legend');
expect(legend).not.toBeInTheDocument();
});
});
describe('prop: disabled', () => {
it('renders with disabled text content', () => {
const { container } = renderWithTheme(<GroupBox disabled />);
const groupBox = container.firstChild as HTMLFieldSetElement;
expect(groupBox).toHaveAttribute('aria-disabled', 'true');
expect(groupBox).toHaveStyleRule('color', theme.materialTextDisabled);
expect(groupBox).toHaveStyleRule(
'text-shadow',
`1px 1px ${theme.materialTextDisabledShadow}`
);
});
});
});