astro-ghostcms/.pnpm-store/v3/files/85/b3d398a329bb5b8f0e5eda440ea...

40 lines
1.3 KiB
Plaintext
Raw Normal View History

2024-02-14 14:10:47 +00:00
import expect from 'expect';
import { elementType } from 'jsx-ast-utils';
import isAbstractRole from '../../../src/util/isAbstractRole';
import {
genElementSymbol,
genAbstractRoleElements,
genNonAbstractRoleElements,
} from '../../../__mocks__/genInteractives';
describe('isAbstractRole', () => {
describe('JSX Components (no tagName)', () => {
it('should NOT identify them as abstract role elements', () => {
expect(isAbstractRole(undefined, []))
.toBe(false);
});
});
describe('elements with an abstract role', () => {
genAbstractRoleElements().forEach(({ openingElement }) => {
const { attributes } = openingElement;
it(`should identify \`${genElementSymbol(openingElement)}\` as an abstract role element`, () => {
expect(isAbstractRole(
elementType(openingElement),
attributes,
)).toBe(true);
});
});
});
describe('elements with a non-abstract role', () => {
genNonAbstractRoleElements().forEach(({ openingElement }) => {
const { attributes } = openingElement;
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as an abstract role element`, () => {
expect(isAbstractRole(
elementType(openingElement),
attributes,
)).toBe(false);
});
});
});
});