|
| 1 | +/* |
| 2 | + * Copyright 2025 Adobe. All rights reserved. |
| 3 | + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); |
| 4 | + * you may not use this file except in compliance with the License. You may obtain a copy |
| 5 | + * of the License at http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | + * |
| 7 | + * Unless required by applicable law or agreed to in writing, software distributed under |
| 8 | + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS |
| 9 | + * OF ANY KIND, either express or implied. See the License for the specific language |
| 10 | + * governing permissions and limitations under the License. |
| 11 | + */ |
| 12 | + |
| 13 | +import React from 'react'; |
| 14 | +import {render} from '@react-spectrum/test-utils-internal'; |
| 15 | +import {Separator, SeparatorContext} from '../'; |
| 16 | + |
| 17 | +describe('Separator', () => { |
| 18 | + it('should render a separator with default class', () => { |
| 19 | + let {getByRole} = render(<Separator />); |
| 20 | + let separator = getByRole('separator'); |
| 21 | + expect(separator.tagName).toBe('HR'); |
| 22 | + expect(separator).toHaveAttribute('class', 'react-aria-Separator'); |
| 23 | + }); |
| 24 | + |
| 25 | + it('should render a separator with custom class', () => { |
| 26 | + let {getByRole} = render(<Separator className="test" />); |
| 27 | + let separator = getByRole('separator'); |
| 28 | + expect(separator).toHaveAttribute('class', 'test'); |
| 29 | + }); |
| 30 | + |
| 31 | + it('should support DOM props', () => { |
| 32 | + let {getByRole} = render(<Separator data-foo="bar" />); |
| 33 | + let separator = getByRole('separator'); |
| 34 | + expect(separator).toHaveAttribute('data-foo', 'bar'); |
| 35 | + }); |
| 36 | + |
| 37 | + it('should support slot', () => { |
| 38 | + let {getByRole} = render( |
| 39 | + <SeparatorContext.Provider value={{slots: {test: {'aria-label': 'test'}}}}> |
| 40 | + <Separator slot="test" /> |
| 41 | + </SeparatorContext.Provider> |
| 42 | + ); |
| 43 | + |
| 44 | + let separator = getByRole('separator'); |
| 45 | + expect(separator).toHaveAttribute('slot', 'test'); |
| 46 | + expect(separator).toHaveAttribute('aria-label', 'test'); |
| 47 | + }); |
| 48 | + |
| 49 | + it('should support accessibility props', () => { |
| 50 | + let {getByRole} = render(<Separator aria-label="label" />); |
| 51 | + let separator = getByRole('separator'); |
| 52 | + expect(separator).toHaveAttribute('aria-label', 'label'); |
| 53 | + }); |
| 54 | +}); |
0 commit comments