Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: align usage of jest expect across tests #827

Merged
merged 1 commit into from Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 20 additions & 14 deletions .eslintrc
@@ -1,31 +1,37 @@
{
extends: [
"extends": [
"airbnb-base",
"plugin:flowtype/recommended"
],
parser: "@babel/eslint-parser",
plugins: [
"flowtype"
"parser": "@babel/eslint-parser",
"plugins": [
"flowtype",
],
rules: {
'max-len': 'off',
'no-template-curly-in-string': 'off',
"rules": {
"max-len": "off",
"no-template-curly-in-string": "off",
},
"overrides": [
{
"files": ["src/rules/*.js"],
"files": ["src/rules/*"],
"extends": ["plugin:eslint-plugin/rules-recommended"],
"rules": {
"eslint-plugin/require-meta-docs-url": [
"error",
{ "pattern": "https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/{{name}}.md" }
{ "pattern": "https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/{{name}}.md" },
],
"eslint-plugin/require-meta-type": "off"
}
"eslint-plugin/require-meta-type": "off",
},
},
{
"files": ["__tests__/src/rules/*.js"],
"extends": ["plugin:eslint-plugin/tests-recommended"]
}
]
"extends": ["plugin:eslint-plugin/tests-recommended"],
},
{
"files": ["__tests__/**/*"],
"env": {
"jest": true,
},
},
],
}
10 changes: 4 additions & 6 deletions __tests__/index-test.js
@@ -1,9 +1,8 @@
/* eslint-env jest */
/* eslint global-require: 0 */

import assert from 'assert';
import fs from 'fs';
import path from 'path';
import expect from 'expect';
import plugin from '../src';

const rules = fs.readdirSync(path.resolve(__dirname, '../src/rules/'))
Expand All @@ -12,8 +11,7 @@ const rules = fs.readdirSync(path.resolve(__dirname, '../src/rules/'))
describe('all rule files should be exported by the plugin', () => {
rules.forEach((ruleName) => {
it(`should export ${ruleName}`, () => {
assert.equal(
plugin.rules[ruleName],
expect(plugin.rules[ruleName]).toEqual(
require(path.join('../src/rules', ruleName)) // eslint-disable-line
);
});
Expand All @@ -22,7 +20,7 @@ describe('all rule files should be exported by the plugin', () => {

describe('configurations', () => {
it('should export a \'recommended\' configuration', () => {
assert(plugin.configs.recommended);
expect(plugin.configs.recommended).toBeDefined();
});
});

Expand All @@ -33,7 +31,7 @@ describe('schemas', () => {
const schema = rule.meta && rule.meta.schema && rule.meta.schema[0];
const { type } = schema;

assert.deepEqual(type, 'object');
expect(type).toEqual('object');
});
});
});
1 change: 0 additions & 1 deletion __tests__/src/rules/accessible-emoji-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce <marquee> elements are not used.
* @author Ethan Cohen
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/alt-text-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce all elements that require alternative text have it.
* @author Ethan Cohen
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/anchor-has-content-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce anchor elements to contain accessible content.
* @author Lisa Ring & Niklas Holmberg
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/anchor-is-valid-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Performs validity check on anchor hrefs. Warns when anchors are used as buttons.
* @author Almero Steyn
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/aria-props-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce all aria-* properties are valid.
* @author Ethan Cohen
Expand Down
2 changes: 1 addition & 1 deletion __tests__/src/rules/aria-proptypes-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce ARIA state and property values are valid.
* @author Ethan Cohen
Expand All @@ -10,6 +9,7 @@

import { aria } from 'aria-query';
import { RuleTester } from 'eslint';
import expect from 'expect';
import parserOptionsMapper from '../../__util__/parserOptionsMapper';
import rule from '../../../src/rules/aria-proptypes';

Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/aria-role-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce aria role attribute is valid.
* @author Ethan Cohen
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/aria-unsupported-elements-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce that elements that do not support ARIA roles,
* states and properties do not have those attributes.
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/autocomplete-valid-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Ensure autocomplete attribute is correct.
* @author Wilco Fiers
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/click-events-have-key-events-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce a clickable non-interactive element has at least 1 keyboard event listener.
* @author Ethan Cohen
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/control-has-associated-label-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Control elements must be associated with a text label
* @author jessebeach
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/heading-has-content-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce heading (h1, h2, etc) elements contain accessible content.
* @author Ethan Cohen
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/html-has-lang-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce html element has lang prop.
* @author Ethan Cohen
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/iframe-has-title-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce iframe elements have a title attribute.
* @author Ethan Cohen
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/img-redundant-alt-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce img alt attribute does not have the word image, picture, or photo.
* @author Ethan Cohen
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/interactive-supports-focus-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce that elements with onClick handlers must be focusable.
* @author Ethan Cohen
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/label-has-associated-control-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce label tags have an associated control.
* @author Jesse Beach
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/label-has-for-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce label tags have htmlFor attribute.
* @author Ethan Cohen
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/lang-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce lang attribute has a valid value.
* @author Ethan Cohen
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/media-has-caption-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview <audio> and <video> elements must have a <track> for captions.
* @author Ethan Cohen
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/mouse-events-have-key-events-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce onmouseover/onmouseout are accompanied
* by onfocus/onblur.
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/no-access-key-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce no accesskey attribute on element.
* @author Ethan Cohen
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/no-autofocus-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce autoFocus prop is not used.
* @author Ethan Cohen <@evcohen>
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/no-distracting-elements-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce distracting elements are not used.
* @author Ethan Cohen
Expand Down
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Disallow inherently interactive elements to be assigned
* non-interactive roles.
Expand Down
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce non-interactive elements have no interactive handlers.
* @author Ethan Cohen
Expand Down
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Disallow inherently non-interactive elements to be assigned
* interactive roles.
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/no-noninteractive-tabindex-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Disallow tabindex on static and noninteractive elements
* @author jessebeach
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/no-onchange-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce usage of onBlur over onChange on select menus for accessibility.
* @author Ethan Cohen
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/no-redundant-roles-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce explicit role property is not the
* same as implicit default role property on element.
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/no-static-element-interactions-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce static elements have no interactive handlers.
* @author Ethan Cohen
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/role-has-required-aria-props-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce that elements with ARIA roles must
* have all required attributes for that role.
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/role-supports-aria-props-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce that an element does not have an unsupported ARIA attribute.
* @author Ethan Cohen
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/scope-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce scope prop is only used on <th> elements.
* @author Ethan Cohen
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/rules/tabindex-no-positive-test.js
@@ -1,4 +1,3 @@
/* eslint-env jest */
/**
* @fileoverview Enforce tabIndex value is not greater than zero.
* @author Ethan Cohen
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/util/attributesComparator-test.js
@@ -1,4 +1,3 @@
/* eslint-env mocha */
import expect from 'expect';
import attributesComparator from '../../../src/util/attributesComparator';
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
Expand Down
2 changes: 1 addition & 1 deletion __tests__/src/util/getComputedRole-test.js
@@ -1,4 +1,4 @@
/* eslint-env jest */
import expect from 'expect';
import getComputedRole from '../../../src/util/getComputedRole';
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';

Expand Down
2 changes: 1 addition & 1 deletion __tests__/src/util/getExplicitRole-test.js
@@ -1,4 +1,4 @@
/* eslint-env jest */
import expect from 'expect';
import getExplicitRole from '../../../src/util/getExplicitRole';
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';

Expand Down
2 changes: 1 addition & 1 deletion __tests__/src/util/getImplicitRole-test.js
@@ -1,4 +1,4 @@
/* eslint-env jest */
import expect from 'expect';
import getImplicitRole from '../../../src/util/getImplicitRole';

describe('getImplicitRole', () => {
Expand Down
13 changes: 6 additions & 7 deletions __tests__/src/util/getSuggestion-test.js
@@ -1,5 +1,4 @@
/* eslint-env jest */
import assert from 'assert';
import expect from 'expect';
import getSuggestion from '../../../src/util/getSuggestion';

describe('spell check suggestion API', () => {
Expand All @@ -8,15 +7,15 @@ describe('spell check suggestion API', () => {
const expected = [];
const actual = getSuggestion(word);

assert.deepEqual(expected, actual);
expect(expected).toEqual(actual);
});

it('should return no suggestions given real word and no dictionary', () => {
const word = 'foo';
const expected = [];
const actual = getSuggestion(word);

assert.deepEqual(expected, actual);
expect(expected).toEqual(actual);
});

it('should return correct suggestion given real word and a dictionary', () => {
Expand All @@ -25,7 +24,7 @@ describe('spell check suggestion API', () => {
const expected = ['foo'];
const actual = getSuggestion(word, dictionary);

assert.deepEqual(expected, actual);
expect(expected).toEqual(actual);
});

it('should return multiple correct suggestions given real word and a dictionary', () => {
Expand All @@ -34,7 +33,7 @@ describe('spell check suggestion API', () => {
const expected = ['there', 'their'];
const actual = getSuggestion(word, dictionary);

assert.deepEqual(expected, actual);
expect(expected).toEqual(actual);
});

it('should return correct # of suggestions given the limit argument', () => {
Expand All @@ -44,6 +43,6 @@ describe('spell check suggestion API', () => {
const expected = 1;
const actual = getSuggestion(word, dictionary, limit).length;

assert.deepEqual(expected, actual);
expect(expected).toEqual(actual);
});
});
2 changes: 1 addition & 1 deletion __tests__/src/util/getTabIndex-test.js
@@ -1,4 +1,4 @@
/* eslint-env jest */
import expect from 'expect';
import getTabIndex from '../../../src/util/getTabIndex';
import IdentifierMock from '../../../__mocks__/IdentifierMock';
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
Expand Down
2 changes: 1 addition & 1 deletion __tests__/src/util/hasAccessibleChild-test.js
@@ -1,4 +1,4 @@
/* eslint-env jest */
import expect from 'expect';
import hasAccessibleChild from '../../../src/util/hasAccessibleChild';
import JSXElementMock from '../../../__mocks__/JSXElementMock';
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/util/implicitRoles/input-test.js
@@ -1,4 +1,3 @@
/* eslint-env mocha */
import expect from 'expect';
import JSXAttributeMock from '../../../../__mocks__/JSXAttributeMock';
import getImplicitRoleForInput from '../../../../src/util/implicitRoles/input';
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/util/implicitRoles/menu-test.js
@@ -1,4 +1,3 @@
/* eslint-env mocha */
import expect from 'expect';
import JSXAttributeMock from '../../../../__mocks__/JSXAttributeMock';
import getImplicitRoleForMenu from '../../../../src/util/implicitRoles/menu';
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/util/implicitRoles/menuitem-test.js
@@ -1,4 +1,3 @@
/* eslint-env mocha */
import expect from 'expect';
import JSXAttributeMock from '../../../../__mocks__/JSXAttributeMock';
import getImplicitRoleForMenuitem from '../../../../src/util/implicitRoles/menuitem';
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/util/isAbstractRole-test.js
@@ -1,4 +1,3 @@
/* eslint-env mocha */
import expect from 'expect';
import { elementType } from 'jsx-ast-utils';
import isAbstractRole from '../../../src/util/isAbstractRole';
Expand Down
3 changes: 1 addition & 2 deletions __tests__/src/util/isDOMElement-test.js
@@ -1,6 +1,5 @@
/* eslint-env mocha */
import { dom } from 'aria-query';
import expect from 'expect';
import { dom } from 'aria-query';
import { elementType } from 'jsx-ast-utils';
import isDOMElement from '../../../src/util/isDOMElement';
import JSXElementMock from '../../../__mocks__/JSXElementMock';
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/util/isDisabledElement-test.js
@@ -1,4 +1,3 @@
/* eslint-env mocha */
import expect from 'expect';
import isDisabledElement from '../../../src/util/isDisabledElement';
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/util/isInteractiveElement-test.js
@@ -1,4 +1,3 @@
/* eslint-env mocha */
import expect from 'expect';
import { elementType } from 'jsx-ast-utils';
import isInteractiveElement from '../../../src/util/isInteractiveElement';
Expand Down