-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(code-snippet): update test suite for CodeSnippet.Skeleton
- Loading branch information
Showing
2 changed files
with
54 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/react/src/components/CodeSnippet/__tests__/CodeSnippet.Skeleton-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* Copyright IBM Corp. 2016, 2018 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import { render, cleanup } from '@carbon/test-utils/react'; | ||
import { settings } from 'carbon-components'; | ||
import React from 'react'; | ||
import { CodeSnippetSkeleton } from '../'; | ||
|
||
const { prefix } = settings; | ||
const snippetTypes = ['single', 'multi']; | ||
|
||
describe('CodeSnippetSkeleton', () => { | ||
afterEach(cleanup); | ||
|
||
describe('automated accessibility testing', () => { | ||
it.each(snippetTypes)( | ||
'should have no Axe violations with type="%s"', | ||
async type => { | ||
const { container } = render(<CodeSnippetSkeleton type={type} />); | ||
await expect(container).toHaveNoAxeViolations(); | ||
} | ||
); | ||
|
||
it.each(snippetTypes)( | ||
'should have no DAP violations with type="%s"', | ||
async type => { | ||
const { container } = render(<CodeSnippetSkeleton type={type} />); | ||
await expect(container).toHaveNoDAPViolations( | ||
`CodeSnippetSkeleton-${type}` | ||
); | ||
} | ||
); | ||
}); | ||
|
||
it('should default to type="single"', () => { | ||
const { container } = render(<CodeSnippetSkeleton />); | ||
expect( | ||
container.querySelector(`.${prefix}--snippet--single`) | ||
).toBeInstanceOf(HTMLElement); | ||
}); | ||
|
||
it('should support a custom `className` on the outer-most element', () => { | ||
const className = 'test'; | ||
const { container } = render(<CodeSnippetSkeleton className={className} />); | ||
expect(container.firstChild.classList.contains(className)).toBe(true); | ||
}); | ||
}); |