|
| 1 | +/** |
| 2 | + * Copyright Zendesk, Inc. |
| 3 | + * |
| 4 | + * Use of this source code is governed under the Apache License, Version 2.0 |
| 5 | + * found at http://www.apache.org/licenses/LICENSE-2.0. |
| 6 | + */ |
| 7 | + |
| 8 | +import React from 'react'; |
| 9 | +import { render, renderRtl } from 'garden-test-utils'; |
| 10 | +import { Kbd } from './Kbd'; |
| 11 | + |
| 12 | +describe('Kbd', () => { |
| 13 | + it('renders the expected element', () => { |
| 14 | + const { container } = render(<Kbd />); |
| 15 | + |
| 16 | + expect(container.firstChild!.nodeName).toBe('KBD'); |
| 17 | + }); |
| 18 | + |
| 19 | + it('forces left-to-right text direction', () => { |
| 20 | + const { container } = renderRtl(<Kbd />); |
| 21 | + |
| 22 | + expect(container.firstChild).toHaveStyleRule('direction', 'ltr'); |
| 23 | + }); |
| 24 | + |
| 25 | + describe('size', () => { |
| 26 | + it('renders inherited size', () => { |
| 27 | + const { container } = render(<Kbd />); |
| 28 | + |
| 29 | + expect(container.firstChild).not.toHaveStyleRule('font-size', 'inherit'); |
| 30 | + }); |
| 31 | + |
| 32 | + it('renders small styling if provided', () => { |
| 33 | + const { container } = render(<Kbd size="small" />); |
| 34 | + |
| 35 | + expect(container.firstChild).toHaveStyleRule('font-size', '11px'); |
| 36 | + }); |
| 37 | + |
| 38 | + it('renders medium styling if provided', () => { |
| 39 | + const { container } = render(<Kbd size="medium" />); |
| 40 | + |
| 41 | + expect(container.firstChild).toHaveStyleRule('font-size', '13px'); |
| 42 | + }); |
| 43 | + |
| 44 | + it('renders large styling if provided', () => { |
| 45 | + const { container } = render(<Kbd size="large" />); |
| 46 | + |
| 47 | + expect(container.firstChild).toHaveStyleRule('font-size', '17px'); |
| 48 | + }); |
| 49 | + }); |
| 50 | +}); |
0 commit comments