|
| 1 | +/* eslint-env mocha */ |
| 2 | +import expect from 'expect'; |
| 3 | +import isSemanticRoleElement from '../../../src/util/isSemanticRoleElement'; |
| 4 | +import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock'; |
| 5 | + |
| 6 | +describe('isSemanticRoleElement', () => { |
| 7 | + it('should identify semantic role elements', () => { |
| 8 | + expect(isSemanticRoleElement('input', [ |
| 9 | + JSXAttributeMock('type', 'checkbox'), |
| 10 | + JSXAttributeMock('role', 'switch'), |
| 11 | + ])).toBe(true); |
| 12 | + }); |
| 13 | + it('should reject non-semantic role elements', () => { |
| 14 | + expect(isSemanticRoleElement('input', [ |
| 15 | + JSXAttributeMock('type', 'radio'), |
| 16 | + JSXAttributeMock('role', 'switch'), |
| 17 | + ])).toBe(false); |
| 18 | + expect(isSemanticRoleElement('input', [ |
| 19 | + JSXAttributeMock('type', 'text'), |
| 20 | + JSXAttributeMock('role', 'combobox'), |
| 21 | + ])).toBe(false); |
| 22 | + expect(isSemanticRoleElement('button', [ |
| 23 | + JSXAttributeMock('role', 'switch'), |
| 24 | + JSXAttributeMock('aria-pressed', 'true'), |
| 25 | + ])).toBe(false); |
| 26 | + expect(isSemanticRoleElement('input', [ |
| 27 | + JSXAttributeMock('role', 'switch'), |
| 28 | + ])).toBe(false); |
| 29 | + }); |
| 30 | +}); |
0 commit comments