Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bde0bd3

Browse files
committed
add tests
1 parent 5aded31 commit bde0bd3

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

‎packages/react-aria-components/test/ColorField.test.js‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,30 @@ describe('ColorField', () => {
8484
expect(input).toHaveValue('');
8585
});
8686

87+
it('should support read-only state', async () => {
88+
let {getByRole, rerender} = render(
89+
<TestColorField />
90+
);
91+
92+
let input = getByRole('textbox');
93+
94+
expect(input.closest('.react-aria-ColorField')).not.toHaveAttribute('data-readonly');
95+
rerender(<TestColorField isReadOnly />);
96+
expect(input.closest('.react-aria-ColorField')).toHaveAttribute('data-readonly');
97+
});
98+
99+
it('should support required state', async () => {
100+
let {getByRole, rerender} = render(
101+
<TestColorField />
102+
);
103+
104+
let input = getByRole('textbox');
105+
106+
expect(input.closest('.react-aria-ColorField')).not.toHaveAttribute('data-required');
107+
rerender(<TestColorField isRequired />);
108+
expect(input.closest('.react-aria-ColorField')).toHaveAttribute('data-required');
109+
});
110+
87111
it('should render data- attributes only on the outer element', () => {
88112
let {getAllByTestId} = render(
89113
<TestColorField data-testid="number-field" />

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /