|
| 1 | +/* |
| 2 | + * Copyright Red Hat, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +import React from 'react'; |
| 18 | + |
| 19 | +import { render } from '@testing-library/react'; |
| 20 | + |
| 21 | +import { Spacer } from './Spacer'; |
| 22 | + |
| 23 | +describe('Spacer', () => { |
| 24 | + it('render some default styles', () => { |
| 25 | + const { container } = render(<Spacer />); |
| 26 | + expect(container.firstElementChild?.getAttribute('style')).toEqual( |
| 27 | + 'flex-grow: 1; min-width: 8px;', |
| 28 | + ); |
| 29 | + }); |
| 30 | + |
| 31 | + it('accepts another grow factor', () => { |
| 32 | + const { container } = render(<Spacer growFactor={2} />); |
| 33 | + expect(container.firstElementChild?.getAttribute('style')).toEqual( |
| 34 | + 'flex-grow: 2; min-width: 8px;', |
| 35 | + ); |
| 36 | + }); |
| 37 | + |
| 38 | + it('accepts number min width', () => { |
| 39 | + const { container } = render(<Spacer minWidth={2} />); |
| 40 | + expect(container.firstElementChild?.getAttribute('style')).toEqual( |
| 41 | + 'flex-grow: 1; min-width: 16px;', |
| 42 | + ); |
| 43 | + }); |
| 44 | + |
| 45 | + it('accepts string min width', () => { |
| 46 | + const { container } = render(<Spacer minWidth="24px" />); |
| 47 | + expect(container.firstElementChild?.getAttribute('style')).toEqual( |
| 48 | + 'flex-grow: 1; min-width: 24px;', |
| 49 | + ); |
| 50 | + }); |
| 51 | + |
| 52 | + it('accepts both', () => { |
| 53 | + const { container } = render(<Spacer growFactor={2} minWidth={2} />); |
| 54 | + expect(container.firstElementChild?.getAttribute('style')).toEqual( |
| 55 | + 'flex-grow: 2; min-width: 16px;', |
| 56 | + ); |
| 57 | + }); |
| 58 | +}); |
0 commit comments