1
0
mirror of synced 2025-12-22 11:26:57 -05:00
Files
docs/tests/rendering/octicon.js
Sarah Schneider aa5a62d49d Remove versions feature flag code (#15793)
* remove FEATURE_NEW_VERSIONS from feature-flags.json

* remove process.env.FEATURE_NEW_VERSIONS from include files

* remove process.env.FEATURE_NEW_VERSIONS from lib files

* remove process.env.FEATURE_NEW_VERSIONS from middleware files

* remove process.env.FEATURE_NEW_VERSIONS from script files

* remove process.env.FEATURE_NEW_VERSIONS from test files

* update test fixtures to use new versions as canonical fixtures
2020-09-29 13:36:07 -04:00

42 lines
1.7 KiB
JavaScript

const renderContent = require('../../lib/render-content')
describe('octicon tag', () => {
it('renders the expected octicon', async () => {
const actual = await renderContent('{% octicon "check" %}')
expect(actual).toContain('<svg ')
expect(actual).toContain('class="octicon octicon-check"')
})
it('renders the expected octicon with an option', async () => {
const actual = await renderContent('{% octicon "check" width="64" %}')
expect(actual).toContain('<svg ')
expect(actual).toContain('class="octicon octicon-check"')
expect(actual).toContain('width="64"')
})
it('renders the expected octicon with multiple options', async () => {
const actual = await renderContent('{% octicon "check" width="64" aria-label="A checkmark" %}')
expect(actual).toContain('<svg ')
expect(actual).toContain('class="octicon octicon-check"')
expect(actual).toContain('width="64"')
expect(actual).toContain('aria-label="A checkmark"')
})
it('uses label to set aria-label', async () => {
const actual = await renderContent('{% octicon "check" label="A checkmark" %}')
expect(actual).toContain('<svg ')
expect(actual).toContain('class="octicon octicon-check"')
expect(actual).toContain('aria-label="A checkmark"')
})
it('throws an error with invalid syntax', async () => {
await expect(renderContent('{% octicon 123 %}')).rejects
.toThrowError('Syntax Error in tag \'octicon\' - Valid syntax: octicon "<name>" <key="value">')
})
it('throws an error with a non-existant octicon', async () => {
await expect(renderContent('{% octicon "pizza-patrol" %}')).rejects
.toThrowError('Octicon pizza-patrol does not exist')
})
})