Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuiliao committed Mar 6, 2025
1 parent 3b2e84d commit 002ddf1
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions packages/react-aria-components/test/Separator.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2025 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

import {render} from '@react-spectrum/test-utils-internal';
import {Separator, SeparatorContext} from '../';


describe('Separator', () => {
it('should render a separator with default class', () => {
let {getByRole} = render(<Separator />);
let separator = getByRole('separator');
expect(separator.tagName).toBe('HR');
expect(separator).toHaveAttribute('class', 'react-aria-Separator');
});

it('should render a separator with custom class', () => {
let {getByRole} = render(<Separator className="test"/>);
let separator = getByRole('separator');
expect(separator).toHaveAttribute('class', 'test');
});

it('should support DOM props', () => {
let {getByRole} = render(<Separator data-foo="bar" />);
let separator = getByRole('separator');
expect(separator).toHaveAttribute('data-foo', 'bar');
});

it('should support slot', () => {
let {getByRole} = render(
<SeparatorContext.Provider value={{slots: {test: {'aria-label': 'test'}}}}>
<Separator slot="test" />
</SeparatorContext.Provider>
);

let separator = getByRole('separator');
expect(separator).toHaveAttribute('slot', 'test');
expect(separator).toHaveAttribute('aria-label', 'test');
});

it('should support accessibility props', () => {
let {getByRole} = render(<Separator aria-label="label" />);
let separator = getByRole('separator');
expect(separator).toHaveAttribute('aria-label', 'label');
});
});

0 comments on commit 002ddf1

Please sign in to comment.