Skip to content
Permalink
9bfb9ba527
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
71 lines (69 sloc) 1.86 KB
import expect from 'expect';
import getComputedRole from '../../../src/util/getComputedRole';
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
describe('getComputedRole', () => {
describe('explicit role', () => {
describe('valid role', () => {
it('should return the role', () => {
expect(getComputedRole(
'div',
[JSXAttributeMock('role', 'button')],
)).toBe('button');
});
});
describe('invalid role', () => {
describe('has implicit', () => {
it('should return the implicit role', () => {
expect(getComputedRole(
'li',
[JSXAttributeMock('role', 'beeswax')],
)).toBe('listitem');
});
});
describe('lacks implicit', () => {
it('should return null', () => {
expect(getComputedRole(
'div',
[JSXAttributeMock('role', 'beeswax')],
)).toBeNull();
});
});
});
describe('no role', () => {
describe('has implicit', () => {
it('should return the implicit role', () => {
expect(getComputedRole(
'li',
[],
)).toBe('listitem');
});
});
describe('lacks implicit', () => {
it('should return null', () => {
expect(getComputedRole(
'div',
[],
)).toBeNull();
});
});
});
});
describe('implicit role', () => {
describe('has implicit', () => {
it('should return the implicit role', () => {
expect(getComputedRole(
'li',
[JSXAttributeMock('role', 'beeswax')],
)).toBe('listitem');
});
});
describe('lacks implicit', () => {
it('should return null', () => {
expect(getComputedRole(
'div',
[],
)).toBeNull();
});
});
});
});