astro-ghostcms/.pnpm-store/v3/files/9d/ac6c22258adceeb74b1397f1bc6...

72 lines
1.9 KiB
Plaintext

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();
});
});
});
});