|
| 1 | +/** |
| 2 | + * Copyright IBM Corp. 2016, 2018 |
| 3 | + * |
| 4 | + * This source code is licensed under the Apache-2.0 license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + */ |
| 7 | + |
| 8 | +import { render, cleanup } from '@carbon/test-utils/react'; |
| 9 | +import { settings } from 'carbon-components'; |
| 10 | +import React from 'react'; |
| 11 | +import { CodeSnippetSkeleton } from '../'; |
| 12 | + |
| 13 | +const { prefix } = settings; |
| 14 | +const snippetTypes = ['single', 'multi']; |
| 15 | + |
| 16 | +describe('CodeSnippetSkeleton', () => { |
| 17 | + afterEach(cleanup); |
| 18 | + |
| 19 | + describe('automated accessibility testing', () => { |
| 20 | + it.each(snippetTypes)( |
| 21 | + 'should have no Axe violations with type="%s"', |
| 22 | + async type => { |
| 23 | + const { container } = render(<CodeSnippetSkeleton type={type} />); |
| 24 | + await expect(container).toHaveNoAxeViolations(); |
| 25 | + } |
| 26 | + ); |
| 27 | + |
| 28 | + it.each(snippetTypes)( |
| 29 | + 'should have no DAP violations with type="%s"', |
| 30 | + async type => { |
| 31 | + const { container } = render(<CodeSnippetSkeleton type={type} />); |
| 32 | + await expect(container).toHaveNoDAPViolations( |
| 33 | + `CodeSnippetSkeleton-${type}` |
| 34 | + ); |
| 35 | + } |
| 36 | + ); |
| 37 | + }); |
| 38 | + |
| 39 | + it('should default to type="single"', () => { |
| 40 | + const { container } = render(<CodeSnippetSkeleton />); |
| 41 | + expect( |
| 42 | + container.querySelector(`.${prefix}--snippet--single`) |
| 43 | + ).toBeInstanceOf(HTMLElement); |
| 44 | + }); |
| 45 | + |
| 46 | + it('should support a custom `className` on the outer-most element', () => { |
| 47 | + const className = 'test'; |
| 48 | + const { container } = render(<CodeSnippetSkeleton className={className} />); |
| 49 | + expect(container.firstChild.classList.contains(className)).toBe(true); |
| 50 | + }); |
| 51 | +}); |
0 commit comments