Skip to content

Commit

Permalink
Upgrade dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
beefancohen committed Oct 22, 2017
1 parent d700045 commit 356944a
Show file tree
Hide file tree
Showing 35 changed files with 294 additions and 468 deletions.
19 changes: 7 additions & 12 deletions __mocks__/genInteractives.js
Expand Up @@ -142,8 +142,8 @@ export function genElementSymbol(openingElement: Object) {
openingElement.name.name +
(openingElement.attributes.length > 0
? `${openingElement.attributes
.map(attr => `[${attr.name.name}="${attr.value.value}"]`)
.join('')}`
.map(attr => `[${attr.name.name}="${attr.value.value}"]`)
.join('')}`
: '')
);
}
Expand All @@ -156,16 +156,14 @@ export function genInteractiveElements() {
name = elementSymbol.slice(0, bracketIndex);
}
const attributes = interactiveElementsMap[elementSymbol].map(({ prop, value }) =>
JSXAttributeMock(prop, value),
);
JSXAttributeMock(prop, value));
return JSXElementMock(name, attributes);
});
}

export function genInteractiveRoleElements() {
return [...interactiveRoles, 'button article', 'fakerole button article'].map(value =>
JSXElementMock('div', [JSXAttributeMock('role', value)]),
);
JSXElementMock('div', [JSXAttributeMock('role', value)]));
}

export function genNonInteractiveElements() {
Expand All @@ -176,16 +174,14 @@ export function genNonInteractiveElements() {
name = elementSymbol.slice(0, bracketIndex);
}
const attributes = nonInteractiveElementsMap[elementSymbol].map(({ prop, value }) =>
JSXAttributeMock(prop, value),
);
JSXAttributeMock(prop, value));
return JSXElementMock(name, attributes);
});
}

export function genNonInteractiveRoleElements() {
return [...nonInteractiveRoles, 'article button', 'fakerole article button'].map(value =>
JSXElementMock('div', [JSXAttributeMock('role', value)]),
);
JSXElementMock('div', [JSXAttributeMock('role', value)]));
}

export function genAbstractRoleElements() {
Expand All @@ -199,8 +195,7 @@ export function genNonAbstractRoleElements() {
export function genIndeterminantInteractiveElements() {
return Object.keys(indeterminantInteractiveElementsMap).map((name) => {
const attributes = indeterminantInteractiveElementsMap[name].map(({ prop, value }) =>
JSXAttributeMock(prop, value),
);
JSXAttributeMock(prop, value));
return JSXElementMock(name, attributes);
});
}
2 changes: 1 addition & 1 deletion __tests__/__util__/parserOptionsMapper.js
Expand Up @@ -8,7 +8,7 @@ const defaultParserOptions = {
export default function parserOptionsMapper({
code,
errors,
options,
options = [],
parserOptions = {},
}) {
return {
Expand Down
19 changes: 5 additions & 14 deletions __tests__/__util__/ruleOptionsMapperFactory.js
Expand Up @@ -4,23 +4,14 @@

type ESLintTestRunnerTestCase = {
code: string,
errors: ?Array<{
message: string,
type: string,
}>,
errors: ?Array<{ message: string, type: string }>,
options: ?Array<mixed>,
parserOptions: ?Array<mixed>,
parserOptions: ?Array<mixed>
};

export default function ruleOptionsMapperFactory(
ruleOptions: Array<mixed> = [],
) {
return ({
code,
errors,
options,
parserOptions,
}: ESLintTestRunnerTestCase): ESLintTestRunnerTestCase => ({
export default function ruleOptionsMapperFactory(ruleOptions: Array<mixed> = []) {
// eslint-disable-next-line
return ({ code, errors, options, parserOptions }: ESLintTestRunnerTestCase): ESLintTestRunnerTestCase => ({
code,
errors,
options: (options || []).concat(ruleOptions),
Expand Down
8 changes: 2 additions & 6 deletions __tests__/src/rules/aria-role-test.js
Expand Up @@ -26,12 +26,8 @@ const errorMessage = {

const roleKeys = [...roles.keys()];

const validRoles = roleKeys.filter(
role => roles.get(role).abstract === false,
);
const invalidRoles = roleKeys.filter(
role => roles.get(role).abstract === true,
);
const validRoles = roleKeys.filter(role => roles.get(role).abstract === false);
const invalidRoles = roleKeys.filter(role => roles.get(role).abstract === true);

const createTests = roleNames => roleNames.map(role => ({
code: `<div role="${role.toLowerCase()}" />`,
Expand Down
10 changes: 2 additions & 8 deletions __tests__/src/rules/interactive-supports-focus-test.js
Expand Up @@ -175,10 +175,7 @@ const passReducer = (roles, handlers, messageTemplate) =>
roleAcc.concat(handlers
.map(handler => ({
code: messageTemplate(element, role, handler),
}),
),
), []),
), []);
}))), [])), []);

const failReducer = (roles, handlers, messageTemplate) =>
staticElements.reduce((elementAcc, element) =>
Expand All @@ -190,10 +187,7 @@ const failReducer = (roles, handlers, messageTemplate) =>
type,
message: messageTemplate(role),
}],
}),
),
), []),
), []);
}))), [])), []);

ruleTester.run(`${ruleName}:recommended`, rule, {
valid: [
Expand Down
80 changes: 16 additions & 64 deletions __tests__/src/util/getTabIndex-test.js
Expand Up @@ -8,124 +8,76 @@ describe('getTabIndex', () => {
describe('as a number ', () => {
describe('zero', () => {
it('should return zero', () => {
expect(
getTabIndex(
JSXAttributeMock('tabIndex', 0),
),
).toBe(0);
expect(getTabIndex(JSXAttributeMock('tabIndex', 0))).toBe(0);
});
});
describe('positive integer', () => {
it('should return the integer', () => {
expect(
getTabIndex(
JSXAttributeMock('tabIndex', 1),
),
).toBe(1);
expect(getTabIndex(JSXAttributeMock('tabIndex', 1))).toBe(1);
});
});
describe('negative integer', () => {
it('should return the integer', () => {
expect(
getTabIndex(
JSXAttributeMock('tabIndex', -1),
),
).toBe(-1);
expect(getTabIndex(JSXAttributeMock('tabIndex', -1))).toBe(-1);
});
});
describe('float', () => {
it('should return undefined', () => {
expect(
getTabIndex(
JSXAttributeMock('tabIndex', 9.1),
),
).toBeUndefined();
expect(getTabIndex(JSXAttributeMock('tabIndex', 9.1))).toBeUndefined();
});
});
});
describe('as a string', () => {
describe('empty', () => {
it('should return undefined', () => {
expect(
getTabIndex(
JSXAttributeMock('tabIndex', ''),
),
).toBeUndefined();
expect(getTabIndex(JSXAttributeMock('tabIndex', ''))).toBeUndefined();
});
});
describe('which converts to a number', () => {
it('should return an integer', () => {
expect(
getTabIndex(
JSXAttributeMock('tabIndex', '0'),
),
).toBe(0);
expect(getTabIndex(JSXAttributeMock('tabIndex', '0'))).toBe(0);
});
});
describe('which is NaN', () => {
it('should return undefined', () => {
expect(
getTabIndex(
JSXAttributeMock('tabIndex', '0a'),
),
).toBeUndefined();
expect(getTabIndex(JSXAttributeMock('tabIndex', '0a'))).toBeUndefined();
});
});
});
describe('as a boolean', () => {
describe('true', () => {
it('should return undefined', () => {
expect(
getTabIndex(
JSXAttributeMock('tabIndex', true),
),
).toBeUndefined();
expect(getTabIndex(JSXAttributeMock('tabIndex', true))).toBeUndefined();
});
});
describe('false', () => {
it('should return undefined', () => {
expect(
getTabIndex(
JSXAttributeMock('tabIndex', false),
),
).toBeUndefined();
expect(getTabIndex(JSXAttributeMock('tabIndex', false))).toBeUndefined();
});
});
});
describe('as an expression', () => {
describe('function expression', () => {
it('should return the correct type', () => {
const attr = function mockFn() { return 0; };
expect(
typeof getTabIndex(
JSXAttributeMock('tabIndex', attr),
),
).toEqual('function');
expect(typeof getTabIndex(JSXAttributeMock('tabIndex', attr))).toEqual('function');
});
});
describe('variable expression', () => {
it('should return the Identifier name', () => {
const name = 'identName';
expect(
getTabIndex(
JSXAttributeMock(
'tabIndex',
IdentifierMock(name),
true,
),
),
).toEqual(name);
expect(getTabIndex(JSXAttributeMock(
'tabIndex',
IdentifierMock(name),
true,
))).toEqual(name);
});
});
});
});
describe('tabIndex is not defined', () => {
it('should return undefined', () => {
expect(
getTabIndex(
JSXAttributeMock('tabIndex', undefined),
),
).toBeUndefined();
expect(getTabIndex(JSXAttributeMock('tabIndex', undefined))).toBeUndefined();
});
});
});
4 changes: 1 addition & 3 deletions __tests__/src/util/hasAccessibleChild-test.js
Expand Up @@ -7,9 +7,7 @@ import JSXExpressionContainerMock from '../../../__mocks__/JSXExpressionContaine
describe('hasAccessibleChild', () => {
describe('has no children and does not set dangerouslySetInnerHTML', () => {
it('returns false', () => {
expect(
hasAccessibleChild(JSXElementMock('div', [])),
).toBe(false);
expect(hasAccessibleChild(JSXElementMock('div', []))).toBe(false);
});
});

Expand Down
40 changes: 18 additions & 22 deletions __tests__/src/util/isAbstractRole-test.js
Expand Up @@ -16,29 +16,25 @@ describe('isAbstractRole', () => {
});
});
describe('elements with an abstract role', () => {
genAbstractRoleElements().forEach(
({ openingElement }) => {
const attributes = openingElement.attributes;
it(`should identify \`${genElementSymbol(openingElement)}\` as an abstract role element`, () => {
expect(isAbstractRole(
elementType(openingElement),
attributes,
)).toBe(true);
});
},
);
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.attributes;
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as an abstract role element`, () => {
expect(isAbstractRole(
elementType(openingElement),
attributes,
)).toBe(false);
});
},
);
genNonAbstractRoleElements().forEach(({ openingElement }) => {
const { attributes } = openingElement;
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as an abstract role element`, () => {
expect(isAbstractRole(
elementType(openingElement),
attributes,
)).toBe(false);
});
});
});
});

0 comments on commit 356944a

Please sign in to comment.