Skip to content

Commit

Permalink
Merge pull request #30 from A11yance/kurosawa-takeshi-add-double-chec…
Browse files Browse the repository at this point in the history
…k-tests

Kurosawa takeshi add double check tests
  • Loading branch information
jessebeach committed Nov 26, 2019
2 parents 08ac721 + fff3783 commit 858607d
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 163 deletions.
15 changes: 15 additions & 0 deletions __tests__/src/ariaPropsMaps-test.js
@@ -1,6 +1,7 @@
/* eslint-env mocha */
import expect from 'expect';
import ariaPropsMap from '../../src/ariaPropsMap';
import rolesMap from '../../src/rolesMap';

describe('ariaPropsMap', function () {
it('should be a Map', function () {
Expand All @@ -9,4 +10,18 @@ describe('ariaPropsMap', function () {
it('should have size', function () {
expect(ariaPropsMap.size).toBeGreaterThan(0);
});

const usedProps = new Set();
for (const roleDefinition of rolesMap.values()) {
for (const prop of Object.keys(roleDefinition.props)) {
usedProps.add(prop);
}
}
for (const prop of ariaPropsMap.keys()) {
describe(prop, function() {
it('should be used in at least one role definition', function() {
expect(usedProps.has(prop)).toBeTruthy(`Expected '${prop}' is used in at least one role definition`);
});
});
}
});
13 changes: 13 additions & 0 deletions __tests__/src/rolesMap-test.js
@@ -1,6 +1,7 @@
/* eslint-env mocha */
import expect from 'expect';
import rolesMap from '../../src/rolesMap';
import ariaPropsMap from '../../src/ariaPropsMap';

describe('rolesMap', function () {
it('should be a Map', function () {
Expand All @@ -10,6 +11,18 @@ describe('rolesMap', function () {
expect(rolesMap.size).toBeGreaterThan(0);
});

test.each(
[...rolesMap.entries()])(
'The definition for role %s has only props defined in ariaPropsMap',
(role, definition) => {

const unknownProps = Object.keys(definition.props).filter((prop) => {
return !ariaPropsMap.has(prop);
});
expect(unknownProps.length).toEqual(0);
}
);

// dpub-aria
describe('doc-abstract role', function () {
const abstract = rolesMap.get('doc-abstract');
Expand Down
184 changes: 23 additions & 161 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -38,7 +38,7 @@
"@babel/core": "^7.6.4",
"@babel/plugin-transform-runtime": "^7.6.2",
"@babel/preset-env": "^7.6.3",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-flow": "^7.7.4",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.0.0",
"commander": "^2.11.0",
Expand All @@ -58,7 +58,7 @@
},
"dependencies": {
"@babel/runtime": "^7.7.4",
"@babel/runtime-corejs3": "^7.6.3"
"@babel/runtime-corejs3": "^7.7.4"
},
"peerDependencies": {
"eslint": "^5 || ^6"
Expand Down

0 comments on commit 858607d

Please sign in to comment.