UNPKG

e-lado

Version:

[![CircleCI](https://circleci.com/gh/sharetribe/sharetribe/tree/master.svg?style=svg)](https://circleci.com/gh/sharetribe/sharetribe/tree/master) [![Dependency Status](https://gemnasium.com/sharetribe/sharetribe.png)](https://gemnasium.com/sharetribe/shar

51 lines (49 loc) 1.77 kB
/* eslint-env mocha */ import expect from 'expect'; import { elementType, getProp, getLiteralPropValue } from 'jsx-ast-utils'; import isInteractiveRole from '../../../src/util/isInteractiveRole'; import { genInteractiveRoleElements, genNonInteractiveRoleElements, } from '../../../__mocks__/genInteractives'; describe('isInteractiveRole', () => { describe('JSX Components (no tagName)', () => { it('should identify them as interactive role elements', () => { expect(isInteractiveRole(undefined, [])) .toBe(true); }); }); describe('elements with a non-interactive role', () => { genNonInteractiveRoleElements().forEach( ({ openingElement }) => { const attributes = openingElement.attributes; const role = getLiteralPropValue(getProp(attributes, 'role')).toLowerCase(); it(`should not identify \`${role}\` as an interactive role element`, () => { expect(isInteractiveRole( elementType(openingElement), attributes, )).toBe(false); }); }, ); }); describe('elements without a role', () => { it('should not identify them as interactive role elements', () => { expect(isInteractiveRole('div', [])).toBe(false); }); }); describe('elements with an interactive role', () => { genInteractiveRoleElements().forEach( ({ openingElement }) => { const attributes = openingElement.attributes; const role = getLiteralPropValue(getProp(attributes, 'role')).toLowerCase(); it(`should identify \`${role}\` as an interactive role element`, () => { expect(isInteractiveRole( elementType(openingElement), attributes, )).toBe(true); }); }, ); }); });