UNPKG

eslint-plugin-lit-a11y

Version:
78 lines (71 loc) โ€ข 2.5 kB
/** * @fileoverview accessible-emoji * @author open-wc */ //------------------------------------------------------------------------------ // Requirements //------------------------------------------------------------------------------ const { RuleTester } = require('eslint'); const rule = require('../../../lib/rules/accessible-emoji.js'); //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ const ruleTester = new RuleTester({ settings: { litHtmlSources: false }, parserOptions: { sourceType: 'module', ecmaVersion: 2015, }, }); ruleTester.run('accessible-emoji', rule, { valid: [ { code: 'html`<div></div>`' }, { code: 'html`<div>asdf</div>`' }, { code: 'html`<span></span>`' }, { code: 'html`<span>No emoji here!</span>`' }, { code: 'html`<span role="img" aria-label="Panda face">๐Ÿผ</span>`' }, { code: 'html`<span role="img" aria-label="Snowman">&#9731;</span>`' }, { code: 'html`<span role="img" aria-labelledby="id1">๐Ÿผ</span>`' }, { code: 'html`<span role="img" aria-labelledby="id1">&#9731;</span>`' }, { code: 'html`<span role="img" aria-labelledby="id1" aria-label="Snowman">&#9731;</span>`' }, { code: 'html`<span>${foo}</span>`' }, { code: 'html`<span aria-hidden>${foo}</span>`' }, { code: 'html`<span aria-hidden="true">๐Ÿผ</span>`' }, { code: 'html`<span aria-hidden>๐Ÿผ</span>`' }, { code: 'html`<div aria-hidden="true">๐Ÿผ</div>`' }, ], invalid: [ { code: 'html`<span>๐Ÿผ</span>`', errors: [{ messageId: 'wrapEmoji' }], }, { code: 'html`<span>foo๐Ÿผbar</span>`', errors: [{ messageId: 'wrapEmoji' }], }, { code: 'html`<span>foo ๐Ÿผ bar</span>`', errors: [{ messageId: 'wrapEmoji' }], }, { code: 'html`<i role="img" aria-label="Panda face">๐Ÿผ</i>`', errors: [{ messageId: 'wrapEmoji' }], }, { code: 'html`<i role="img" aria-labelledby="id1">๐Ÿผ</i>`', errors: [{ messageId: 'wrapEmoji' }], }, { code: 'html`<span aria-hidden="false">๐Ÿผ</span>`', errors: [{ messageId: 'wrapEmoji' }], }, { code: 'html`<span role="img" alt="Panda face">๐Ÿผ</span>`', errors: [{ messageId: 'wrapEmoji' }], }, { code: 'html`<span role="img" alt="Panda face">๐Ÿผ</span>`', errors: [{ messageId: 'wrapEmoji' }], }, ], });