Skip to content

Commit a284cbf

Browse files
committedSep 3, 2024··
[Tests] switch from jest to tape
This allows us to: - drop all the jest mocks - no longer be stuck on an EOL version nor be forced to raise the engines.node threshold - run tests 4x faster: jest takes 27.365s, tape takes 7.086s
1 parent deac4fd commit a284cbf

40 files changed

+1723
-1315
lines changed
 

‎.github/workflows/node-4+.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ jobs:
128128
skip-ls-check: true
129129
- run: rm __tests__/src/util/getComputedRole-test.js
130130
if: ${{ matrix.node-version < 7 }}
131-
- run: npm run test:ci
131+
- run: npm run tests-only
132132
- uses: codecov/codecov-action@v3.1.5
133133

134134
node:

‎__tests__/__util__/nodeReexports/assert.js

-3
This file was deleted.

‎__tests__/__util__/nodeReexports/fs-promises.js

-3
This file was deleted.

‎__tests__/__util__/nodeReexports/fs.js

-3
This file was deleted.

‎__tests__/__util__/nodeReexports/path.js

-3
This file was deleted.

‎__tests__/__util__/nodeReexports/url.js

-3
This file was deleted.

‎__tests__/__util__/nodeReexports/util.js

-3
This file was deleted.

‎__tests__/index-test.js

+21-18
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,39 @@
22

33
import fs from 'fs';
44
import path from 'path';
5-
import expect from 'expect';
5+
import test from 'tape';
6+
67
import plugin from '../src';
78

89
const rules = fs.readdirSync(path.resolve(__dirname, '../src/rules/'))
910
.map((f) => path.basename(f, '.js'));
1011

11-
describe('all rule files should be exported by the plugin', () => {
12+
test('all rule files should be exported by the plugin', (t) => {
1213
rules.forEach((ruleName) => {
13-
it(`should export ${ruleName}`, () => {
14-
expect(plugin.rules[ruleName]).toEqual(
15-
require(path.join('../src/rules', ruleName)) // eslint-disable-line
16-
);
17-
});
14+
t.equal(
15+
plugin.rules[ruleName],
16+
require(path.join('../src/rules', ruleName)), // eslint-disable-line import/no-dynamic-require
17+
`exports ${ruleName}`,
18+
);
1819
});
20+
21+
t.end();
1922
});
2023

21-
describe('configurations', () => {
22-
it('should export a \'recommended\' configuration', () => {
23-
expect(plugin.configs.recommended).toBeDefined();
24-
});
24+
test('configurations', (t) => {
25+
t.notEqual(plugin.configs.recommended, undefined, 'exports a \'recommended\' configuration');
26+
27+
t.end();
2528
});
2629

27-
describe('schemas', () => {
30+
test('schemas', (t) => {
2831
rules.forEach((ruleName) => {
29-
it(`${ruleName} should export a schema with type object`, () => {
30-
const rule = require(path.join('../src/rules', ruleName)); // eslint-disable-line
31-
const schema = rule.meta && rule.meta.schema && rule.meta.schema[0];
32-
const { type } = schema;
32+
const rule = require(path.join('../src/rules', ruleName)); // eslint-disable-line import/no-dynamic-require
33+
const schema = rule.meta && rule.meta.schema && rule.meta.schema[0];
34+
const { type } = schema;
3335

34-
expect(type).toEqual('object');
35-
});
36+
t.equal(type, 'object', `${ruleName} exports a schema with type object`);
3637
});
38+
39+
t.end();
3740
});

‎__tests__/src/rules/anchor-ambiguous-text-test.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-env jest */
21
/**
32
* @fileoverview Enforce `<a>` text to not exactly match "click here", "here", "link", or "a link".
43
* @author Matt Wang

‎__tests__/src/rules/aria-proptypes-test.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
import { aria } from 'aria-query';
1111
import { RuleTester } from 'eslint';
12-
import expect from 'expect';
12+
import test from 'tape';
13+
1314
import parserOptionsMapper from '../../__util__/parserOptionsMapper';
1415
import parsers from '../../__util__/helpers/parsers';
1516
import rule from '../../../src/rules/aria-proptypes';
@@ -51,13 +52,14 @@ tokens from the following: ${permittedValues}.`,
5152
}
5253
};
5354

54-
describe('validityCheck', () => {
55-
it('should false for an unknown expected type', () => {
56-
expect(validityCheck(
57-
null,
58-
null,
59-
)).toBe(false);
60-
});
55+
test('validityCheck', (t) => {
56+
t.equal(
57+
validityCheck(null, null),
58+
false,
59+
'is false for an unknown expected type',
60+
);
61+
62+
t.end();
6163
});
6264

6365
ruleTester.run('aria-proptypes', rule, {
+86-110
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,91 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import attributesComparator from '../../../src/util/attributesComparator';
34
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
45
import JSXElementMock from '../../../__mocks__/JSXElementMock';
56

6-
describe('attributesComparator', () => {
7-
describe('base attributes', () => {
8-
let baseAttributes;
9-
let attributes;
10-
describe('are undefined', () => {
11-
describe('and attributes are undefined', () => {
12-
it('should return true', () => {
13-
expect(attributesComparator()).toBe(true);
14-
});
15-
});
16-
});
17-
describe('are empty', () => {
18-
beforeEach(() => {
19-
baseAttributes = [];
20-
});
21-
describe('and attributes', () => {
22-
describe('are empty', () => {
23-
attributes = [];
24-
it('should return true', () => {
25-
expect(attributesComparator(baseAttributes, attributes))
26-
.toBe(true);
27-
});
28-
});
29-
describe('have values', () => {
30-
attributes = [
31-
JSXAttributeMock('foo', 0),
32-
JSXAttributeMock('bar', 'baz'),
33-
];
34-
it('should return true', () => {
35-
expect(attributesComparator(baseAttributes, attributes))
36-
.toBe(true);
37-
});
38-
});
39-
});
40-
});
41-
describe('have values', () => {
42-
beforeEach(() => {
43-
baseAttributes = [
44-
{
45-
name: 'biz',
46-
value: 1,
47-
}, {
48-
name: 'fizz',
49-
value: 'pop',
50-
}, {
51-
name: 'fuzz',
52-
value: 'lolz',
53-
},
54-
];
55-
});
56-
describe('and attributes', () => {
57-
describe('are empty', () => {
58-
attributes = [];
59-
it('should return false', () => {
60-
expect(attributesComparator(baseAttributes, attributes))
61-
.toBe(false);
62-
});
63-
});
64-
describe('have values', () => {
65-
describe('and the values are the different', () => {
66-
it('should return false', () => {
67-
attributes = [
68-
JSXElementMock(),
69-
JSXAttributeMock('biz', 2),
70-
JSXAttributeMock('ziff', 'opo'),
71-
JSXAttributeMock('far', 'lolz'),
72-
];
73-
expect(attributesComparator(baseAttributes, attributes))
74-
.toBe(false);
75-
});
76-
});
77-
describe('and the values are a subset', () => {
78-
it('should return true', () => {
79-
attributes = [
80-
JSXAttributeMock('biz', 1),
81-
JSXAttributeMock('fizz', 'pop'),
82-
JSXAttributeMock('goo', 'gazz'),
83-
];
84-
expect(attributesComparator(baseAttributes, attributes))
85-
.toBe(false);
86-
});
87-
});
88-
describe('and the values are the same', () => {
89-
it('should return true', () => {
90-
attributes = [
91-
JSXAttributeMock('biz', 1),
92-
JSXAttributeMock('fizz', 'pop'),
93-
JSXAttributeMock('fuzz', 'lolz'),
94-
];
95-
expect(attributesComparator(baseAttributes, attributes))
96-
.toBe(true);
97-
});
98-
});
99-
describe('and the values are a superset', () => {
100-
it('should return true', () => {
101-
attributes = [
102-
JSXAttributeMock('biz', 1),
103-
JSXAttributeMock('fizz', 'pop'),
104-
JSXAttributeMock('fuzz', 'lolz'),
105-
JSXAttributeMock('dar', 'tee'),
106-
];
107-
expect(attributesComparator(baseAttributes, attributes))
108-
.toBe(true);
109-
});
110-
});
111-
});
112-
});
113-
});
114-
});
7+
test('attributesComparator', (t) => {
8+
t.equal(
9+
attributesComparator(),
10+
true,
11+
'baseAttributes are undefined and attributes are undefined -> true',
12+
);
13+
14+
t.equal(
15+
attributesComparator([], []),
16+
true,
17+
'baseAttributes are empty and attributes are empty -> true',
18+
);
19+
20+
t.equal(
21+
attributesComparator([], [
22+
JSXAttributeMock('foo', 0),
23+
JSXAttributeMock('bar', 'baz'),
24+
]),
25+
true,
26+
'baseAttributes are empty and attributes have values -> true',
27+
);
28+
29+
const baseAttributes = [
30+
{
31+
name: 'biz',
32+
value: 1,
33+
}, {
34+
name: 'fizz',
35+
value: 'pop',
36+
}, {
37+
name: 'fuzz',
38+
value: 'lolz',
39+
},
40+
];
41+
42+
t.equal(
43+
attributesComparator(baseAttributes, []),
44+
false,
45+
'baseAttributes have values and attributes are empty -> false',
46+
);
47+
48+
t.equal(
49+
attributesComparator(baseAttributes, [
50+
JSXElementMock(),
51+
JSXAttributeMock('biz', 2),
52+
JSXAttributeMock('ziff', 'opo'),
53+
JSXAttributeMock('far', 'lolz'),
54+
]),
55+
false,
56+
'baseAttributes have values and attributes have values, and the values are different -> false',
57+
);
58+
59+
t.equal(
60+
attributesComparator(baseAttributes, [
61+
JSXAttributeMock('biz', 1),
62+
JSXAttributeMock('fizz', 'pop'),
63+
JSXAttributeMock('goo', 'gazz'),
64+
]),
65+
false,
66+
'baseAttributes have values and attributes have values, and the values are a subset -> false',
67+
);
68+
69+
t.equal(
70+
attributesComparator(baseAttributes, [
71+
JSXAttributeMock('biz', 1),
72+
JSXAttributeMock('fizz', 'pop'),
73+
JSXAttributeMock('fuzz', 'lolz'),
74+
]),
75+
true,
76+
'baseAttributes have values and attributes have values, and the values are the same -> true',
77+
);
78+
79+
t.equal(
80+
attributesComparator(baseAttributes, [
81+
JSXAttributeMock('biz', 1),
82+
JSXAttributeMock('fizz', 'pop'),
83+
JSXAttributeMock('fuzz', 'lolz'),
84+
JSXAttributeMock('dar', 'tee'),
85+
]),
86+
true,
87+
'baseAttributes have values and attributes have values, and the values are a superset -> true',
88+
);
89+
90+
t.end();
11591
});
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,130 @@
1-
import expect from 'expect';
1+
import test from 'tape';
22
import { elementType } from 'jsx-ast-utils';
3+
34
import getAccessibleChildText from '../../../src/util/getAccessibleChildText';
45
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
56
import JSXElementMock from '../../../__mocks__/JSXElementMock';
67

7-
describe('getAccessibleChildText', () => {
8-
it('returns the aria-label when present', () => {
9-
expect(getAccessibleChildText(JSXElementMock(
8+
test('getAccessibleChildText', (t) => {
9+
t.equal(
10+
getAccessibleChildText(JSXElementMock(
1011
'a',
1112
[JSXAttributeMock('aria-label', 'foo')],
12-
), elementType)).toBe('foo');
13-
});
13+
), elementType),
14+
'foo',
15+
'returns the aria-label when present',
16+
);
1417

15-
it('returns the aria-label instead of children', () => {
16-
expect(getAccessibleChildText(JSXElementMock(
18+
t.equal(
19+
getAccessibleChildText(JSXElementMock(
1720
'a',
1821
[JSXAttributeMock('aria-label', 'foo')],
1922
[{ type: 'JSXText', value: 'bar' }],
20-
), elementType)).toBe('foo');
21-
});
23+
), elementType),
24+
'foo',
25+
'returns the aria-label instead of children',
26+
);
2227

23-
it('skips elements with aria-hidden=true', () => {
24-
expect(getAccessibleChildText(JSXElementMock(
28+
t.equal(
29+
getAccessibleChildText(JSXElementMock(
2530
'a',
2631
[JSXAttributeMock('aria-hidden', 'true')],
27-
), elementType)).toBe('');
28-
});
32+
), elementType),
33+
'',
34+
'skips elements with aria-hidden=true',
35+
);
2936

30-
it('returns literal value for JSXText child', () => {
31-
expect(getAccessibleChildText(JSXElementMock(
37+
t.equal(
38+
getAccessibleChildText(JSXElementMock(
3239
'a',
3340
[],
3441
[{ type: 'JSXText', value: 'bar' }],
35-
), elementType)).toBe('bar');
36-
});
42+
), elementType),
43+
'bar',
44+
'returns literal value for JSXText child',
45+
);
3746

38-
it('returns alt text for img child', () => {
39-
expect(getAccessibleChildText(JSXElementMock(
47+
t.equal(
48+
getAccessibleChildText(JSXElementMock(
4049
'a',
4150
[],
4251
[JSXElementMock('img', [
4352
JSXAttributeMock('src', 'some/path'),
4453
JSXAttributeMock('alt', 'a sensible label'),
4554
])],
46-
), elementType)).toBe('a sensible label');
47-
});
55+
), elementType),
56+
'a sensible label',
57+
'returns alt text for img child',
58+
);
4859

49-
it('returns blank when alt tag is used on arbitrary element', () => {
50-
expect(getAccessibleChildText(JSXElementMock(
60+
t.equal(
61+
getAccessibleChildText(JSXElementMock(
5162
'a',
5263
[],
5364
[JSXElementMock('span', [
5465
JSXAttributeMock('alt', 'a sensible label'),
5566
])],
56-
), elementType)).toBe('');
57-
});
67+
), elementType),
68+
'',
69+
'returns blank when alt tag is used on arbitrary element',
70+
);
5871

59-
it('returns literal value for JSXText child', () => {
60-
expect(getAccessibleChildText(JSXElementMock(
72+
t.equal(
73+
getAccessibleChildText(JSXElementMock(
6174
'a',
6275
[],
6376
[{ type: 'Literal', value: 'bar' }],
64-
), elementType)).toBe('bar');
65-
});
77+
), elementType),
78+
'bar',
79+
'returns literal value for JSXText child',
80+
);
6681

67-
it('returns trimmed literal value for JSXText child', () => {
68-
expect(getAccessibleChildText(JSXElementMock(
82+
t.equal(
83+
getAccessibleChildText(JSXElementMock(
6984
'a',
7085
[],
7186
[{ type: 'Literal', value: ' bar ' }],
72-
), elementType)).toBe('bar');
73-
});
87+
), elementType),
88+
'bar',
89+
'returns trimmed literal value for JSXText child',
90+
);
7491

75-
it('returns space-collapsed literal value for JSXText child', () => {
76-
expect(getAccessibleChildText(JSXElementMock(
92+
t.equal(
93+
getAccessibleChildText(JSXElementMock(
7794
'a',
7895
[],
7996
[{ type: 'Literal', value: 'foo bar' }],
80-
), elementType)).toBe('foo bar');
81-
});
97+
), elementType),
98+
'foo bar',
99+
'returns space-collapsed literal value for JSXText child',
100+
);
82101

83-
it('returns punctuation-stripped literal value for JSXText child', () => {
84-
expect(getAccessibleChildText(JSXElementMock(
102+
t.equal(
103+
getAccessibleChildText(JSXElementMock(
85104
'a',
86105
[],
87106
[{ type: 'Literal', value: 'foo, bar. baz? foo; bar:' }],
88-
), elementType)).toBe('foo bar baz foo bar');
89-
});
107+
), elementType),
108+
'foo bar baz foo bar',
109+
'returns punctuation-stripped literal value for JSXText child',
110+
);
90111

91-
it('returns recursive value for JSXElement child', () => {
92-
expect(getAccessibleChildText(JSXElementMock(
112+
t.equal(
113+
getAccessibleChildText(JSXElementMock(
93114
'a',
94115
[],
95116
[JSXElementMock(
96117
'span',
97118
[],
98119
[{ type: 'Literal', value: 'bar' }],
99120
)],
100-
), elementType)).toBe('bar');
101-
});
121+
), elementType),
122+
'bar',
123+
'returns recursive value for JSXElement child',
124+
);
102125

103-
it('skips children with aria-hidden-true', () => {
104-
expect(getAccessibleChildText(JSXElementMock(
126+
t.equal(
127+
getAccessibleChildText(JSXElementMock(
105128
'a',
106129
[],
107130
[JSXElementMock(
@@ -112,30 +135,40 @@ describe('getAccessibleChildText', () => {
112135
[JSXAttributeMock('aria-hidden', 'true')],
113136
)],
114137
)],
115-
), elementType)).toBe('');
116-
});
138+
), elementType),
139+
'',
140+
'skips children with aria-hidden-true',
141+
);
117142

118-
it('joins multiple children properly - no spacing', () => {
119-
expect(getAccessibleChildText(JSXElementMock(
143+
t.equal(
144+
getAccessibleChildText(JSXElementMock(
120145
'a',
121146
[],
122147
[{ type: 'Literal', value: 'foo' }, { type: 'Literal', value: 'bar' }],
123-
), elementType)).toBe('foo bar');
124-
});
148+
), elementType),
149+
'foo bar',
150+
'joins multiple children properly - no spacing',
151+
);
125152

126-
it('joins multiple children properly - with spacing', () => {
127-
expect(getAccessibleChildText(JSXElementMock(
153+
t.equal(
154+
getAccessibleChildText(JSXElementMock(
128155
'a',
129156
[],
130157
[{ type: 'Literal', value: ' foo ' }, { type: 'Literal', value: ' bar ' }],
131-
), elementType)).toBe('foo bar');
132-
});
158+
), elementType),
159+
'foo bar',
160+
'joins multiple children properly - with spacing',
161+
);
133162

134-
it('skips unknown elements', () => {
135-
expect(getAccessibleChildText(JSXElementMock(
163+
t.equal(
164+
getAccessibleChildText(JSXElementMock(
136165
'a',
137166
[],
138167
[{ type: 'Literal', value: 'foo' }, { type: 'Unknown' }, { type: 'Literal', value: 'bar' }],
139-
), elementType)).toBe('foo bar');
140-
});
168+
), elementType),
169+
'foo bar',
170+
'skips unknown elements',
171+
);
172+
173+
t.end();
141174
});
+66-66
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,71 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import getComputedRole from '../../../src/util/getComputedRole';
34
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
45

5-
describe('getComputedRole', () => {
6-
describe('explicit role', () => {
7-
describe('valid role', () => {
8-
it('should return the role', () => {
9-
expect(getComputedRole(
10-
'div',
11-
[JSXAttributeMock('role', 'button')],
12-
)).toBe('button');
13-
});
14-
});
15-
describe('invalid role', () => {
16-
describe('has implicit', () => {
17-
it('should return the implicit role', () => {
18-
expect(getComputedRole(
19-
'li',
20-
[JSXAttributeMock('role', 'beeswax')],
21-
)).toBe('listitem');
22-
});
23-
});
24-
describe('lacks implicit', () => {
25-
it('should return null', () => {
26-
expect(getComputedRole(
27-
'div',
28-
[JSXAttributeMock('role', 'beeswax')],
29-
)).toBeNull();
30-
});
31-
});
32-
});
6+
test('getComputedRole', (t) => {
7+
t.equal(
8+
getComputedRole(
9+
'div',
10+
[JSXAttributeMock('role', 'button')],
11+
),
12+
'button',
13+
'explicit role + valid role -> returns the role',
14+
);
15+
16+
t.equal(
17+
getComputedRole(
18+
'li',
19+
[JSXAttributeMock('role', 'beeswax')],
20+
),
21+
'listitem',
22+
'explicit role + invalid role + has implicit -> returns the implicit role',
23+
);
24+
25+
t.equal(
26+
getComputedRole(
27+
'div',
28+
[JSXAttributeMock('role', 'beeswax')],
29+
),
30+
null,
31+
'explicit role + invalid role + lacks implicit -> returns null',
32+
);
33+
34+
t.equal(
35+
getComputedRole(
36+
'li',
37+
[],
38+
),
39+
'listitem',
40+
'explicit role + no role + has implicit -> returns the implicit role',
41+
);
42+
43+
t.equal(
44+
getComputedRole(
45+
'div',
46+
[],
47+
),
48+
null,
49+
'explicit role + no role + lacks implicit -> returns null',
50+
);
51+
52+
t.equal(
53+
getComputedRole(
54+
'li',
55+
[JSXAttributeMock('role', 'beeswax')],
56+
),
57+
'listitem',
58+
'implicit role + has implicit -> returns the implicit role',
59+
);
60+
61+
t.equal(
62+
getComputedRole(
63+
'div',
64+
[],
65+
),
66+
null,
67+
'implicit role + lacks implicit -> returns null',
68+
);
3369

34-
describe('no role', () => {
35-
describe('has implicit', () => {
36-
it('should return the implicit role', () => {
37-
expect(getComputedRole(
38-
'li',
39-
[],
40-
)).toBe('listitem');
41-
});
42-
});
43-
describe('lacks implicit', () => {
44-
it('should return null', () => {
45-
expect(getComputedRole(
46-
'div',
47-
[],
48-
)).toBeNull();
49-
});
50-
});
51-
});
52-
});
53-
describe('implicit role', () => {
54-
describe('has implicit', () => {
55-
it('should return the implicit role', () => {
56-
expect(getComputedRole(
57-
'li',
58-
[JSXAttributeMock('role', 'beeswax')],
59-
)).toBe('listitem');
60-
});
61-
});
62-
describe('lacks implicit', () => {
63-
it('should return null', () => {
64-
expect(getComputedRole(
65-
'div',
66-
[],
67-
)).toBeNull();
68-
});
69-
});
70-
});
70+
t.end();
7171
});
+69-38
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import getElementType from '../../../src/util/getElementType';
34
import JSXElementMock from '../../../__mocks__/JSXElementMock';
45
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
56

6-
describe('getElementType', () => {
7-
describe('no settings in context', () => {
7+
test('getElementType', (t) => {
8+
t.test('no settings in context', (st) => {
89
const elementType = getElementType({ settings: {} });
910

10-
it('should return the exact tag name for a DOM element', () => {
11-
expect(elementType(JSXElementMock('input').openingElement)).toBe('input');
12-
});
11+
st.equal(
12+
elementType(JSXElementMock('input').openingElement),
13+
'input',
14+
'returns the exact tag name for a DOM element',
15+
);
1316

14-
it('should return the exact tag name for a custom element', () => {
15-
expect(elementType(JSXElementMock('CustomInput').openingElement)).toBe('CustomInput');
16-
});
17+
st.equal(
18+
elementType(JSXElementMock('CustomInput').openingElement),
19+
'CustomInput',
20+
'returns the exact tag name for a custom element',
21+
);
1722

18-
it('should return the exact tag name for names that are in Object.prototype', () => {
19-
expect(elementType(JSXElementMock('toString').openingElement)).toBe('toString');
20-
});
23+
st.equal(
24+
elementType(JSXElementMock('toString').openingElement),
25+
'toString',
26+
'returns the exact tag name for names that are in Object.prototype',
27+
);
2128

22-
it('should return the default tag name provided', () => {
23-
expect(elementType(JSXElementMock('span', [JSXAttributeMock('as', 'h1')]).openingElement)).toBe('span');
24-
});
29+
st.equal(
30+
elementType(JSXElementMock('span', [JSXAttributeMock('as', 'h1')]).openingElement),
31+
'span',
32+
'returns the default tag name provided',
33+
);
34+
35+
st.end();
2536
});
2637

27-
describe('components settings in context', () => {
38+
t.test('components settings in context', (st) => {
2839
const elementType = getElementType({
2940
settings: {
3041
'jsx-a11y': {
@@ -35,24 +46,34 @@ describe('getElementType', () => {
3546
},
3647
});
3748

38-
it('should return the exact tag name for a DOM element', () => {
39-
expect(elementType(JSXElementMock('input').openingElement)).toBe('input');
40-
});
49+
st.equal(
50+
elementType(JSXElementMock('input').openingElement),
51+
'input',
52+
'returns the exact tag name for a DOM element',
53+
);
4154

42-
it('should return the mapped tag name for a custom element', () => {
43-
expect(elementType(JSXElementMock('CustomInput').openingElement)).toBe('input');
44-
});
55+
st.equal(
56+
elementType(JSXElementMock('CustomInput').openingElement),
57+
'input',
58+
'returns the mapped tag name for a custom element',
59+
);
4560

46-
it('should return the exact tag name for a custom element not in the components map', () => {
47-
expect(elementType(JSXElementMock('CityInput').openingElement)).toBe('CityInput');
48-
});
61+
st.equal(
62+
elementType(JSXElementMock('CityInput').openingElement),
63+
'CityInput',
64+
'returns the exact tag name for a custom element not in the components map',
65+
);
4966

50-
it('should return the default tag name since not polymorphicPropName was provided', () => {
51-
expect(elementType(JSXElementMock('span', [JSXAttributeMock('as', 'h1')]).openingElement)).toBe('span');
52-
});
67+
st.equal(
68+
elementType(JSXElementMock('span', [JSXAttributeMock('as', 'h1')]).openingElement),
69+
'span',
70+
'return the default tag name since not polymorphicPropName was provided',
71+
);
72+
73+
st.end();
5374
});
5475

55-
describe('polymorphicPropName settings in context', () => {
76+
t.test('polymorphicPropName settings in context', (st) => {
5677
const elementType = getElementType({
5778
settings: {
5879
'jsx-a11y': {
@@ -64,16 +85,26 @@ describe('getElementType', () => {
6485
},
6586
});
6687

67-
it('should return the tag name provided by the polymorphic prop, "asChild", defined in the settings', () => {
68-
expect(elementType(JSXElementMock('span', [JSXAttributeMock('asChild', 'h1')]).openingElement)).toBe('h1');
69-
});
88+
st.equal(
89+
elementType(JSXElementMock('span', [JSXAttributeMock('asChild', 'h1')]).openingElement),
90+
'h1',
91+
'returns the tag name provided by the polymorphic prop, "asChild", defined in the settings',
92+
);
7093

71-
it('should return the tag name provided by the polymorphic prop, "asChild", defined in the settings instead of the component mapping tag', () => {
72-
expect(elementType(JSXElementMock('CustomButton', [JSXAttributeMock('asChild', 'a')]).openingElement)).toBe('a');
73-
});
94+
st.equal(
95+
elementType(JSXElementMock('CustomButton', [JSXAttributeMock('asChild', 'a')]).openingElement),
96+
'a',
97+
'returns the tag name provided by the polymorphic prop, "asChild", defined in the settings instead of the component mapping tag',
98+
);
7499

75-
it('should return the tag name provided by the componnet mapping if the polymorphic prop, "asChild", defined in the settings is not set', () => {
76-
expect(elementType(JSXElementMock('CustomButton', [JSXAttributeMock('as', 'a')]).openingElement)).toBe('button');
77-
});
100+
st.equal(
101+
elementType(JSXElementMock('CustomButton', [JSXAttributeMock('as', 'a')]).openingElement),
102+
'button',
103+
'returns the tag name provided by the componnet mapping if the polymorphic prop, "asChild", defined in the settings is not set',
104+
);
105+
106+
st.end();
78107
});
108+
109+
t.end();
79110
});
+31-26
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import getExplicitRole from '../../../src/util/getExplicitRole';
34
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
45

5-
describe('getExplicitRole', () => {
6-
describe('valid role', () => {
7-
it('should return the role', () => {
8-
expect(getExplicitRole(
9-
'div',
10-
[JSXAttributeMock('role', 'button')],
11-
)).toBe('button');
12-
});
13-
});
14-
describe('invalid role', () => {
15-
it('should return null', () => {
16-
expect(getExplicitRole(
17-
'div',
18-
[JSXAttributeMock('role', 'beeswax')],
19-
)).toBeNull();
20-
});
21-
});
22-
describe('no role', () => {
23-
it('should return null', () => {
24-
expect(getExplicitRole(
25-
'div',
26-
[],
27-
)).toBeNull();
28-
});
29-
});
6+
test('getExplicitRole', (t) => {
7+
t.equal(
8+
getExplicitRole(
9+
'div',
10+
[JSXAttributeMock('role', 'button')],
11+
),
12+
'button',
13+
'valid role returns the role',
14+
);
15+
16+
t.equal(
17+
getExplicitRole(
18+
'div',
19+
[JSXAttributeMock('role', 'beeswax')],
20+
),
21+
null,
22+
'invalid role returns null',
23+
);
24+
25+
t.equal(
26+
getExplicitRole(
27+
'div',
28+
[],
29+
),
30+
null,
31+
'no role returns null',
32+
);
33+
34+
t.end();
3035
});
+22-18
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import getImplicitRole from '../../../src/util/getImplicitRole';
34

4-
describe('getImplicitRole', () => {
5-
describe('has implicit', () => {
6-
it('should return the implicit role', () => {
7-
expect(getImplicitRole(
8-
'li',
9-
[],
10-
)).toBe('listitem');
11-
});
12-
});
13-
describe('lacks implicit', () => {
14-
it('should return null', () => {
15-
expect(getImplicitRole(
16-
'div',
17-
[],
18-
)).toBeNull();
19-
});
20-
});
5+
test('getImplicitRole', (t) => {
6+
t.equal(
7+
getImplicitRole(
8+
'li',
9+
[],
10+
),
11+
'listitem',
12+
'has implicit, returns implicit role',
13+
);
14+
15+
t.equal(
16+
getImplicitRole(
17+
'div',
18+
[],
19+
),
20+
null,
21+
'lacks implicit, returns null',
22+
);
23+
24+
t.end();
2125
});
+30-45
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,33 @@
1-
import expect from 'expect';
2-
import getSuggestion from '../../../src/util/getSuggestion';
3-
4-
describe('spell check suggestion API', () => {
5-
it('should return no suggestions given empty word and no dictionary', () => {
6-
const word = '';
7-
const expected = [];
8-
const actual = getSuggestion(word);
9-
10-
expect(expected).toEqual(actual);
11-
});
12-
13-
it('should return no suggestions given real word and no dictionary', () => {
14-
const word = 'foo';
15-
const expected = [];
16-
const actual = getSuggestion(word);
17-
18-
expect(expected).toEqual(actual);
19-
});
1+
import test from 'tape';
202

21-
it('should return correct suggestion given real word and a dictionary', () => {
22-
const word = 'fo';
23-
const dictionary = ['foo', 'bar', 'baz'];
24-
const expected = ['foo'];
25-
const actual = getSuggestion(word, dictionary);
26-
27-
expect(expected).toEqual(actual);
28-
});
29-
30-
it('should return multiple correct suggestions given real word and a dictionary', () => {
31-
const word = 'theer';
32-
const dictionary = ['there', 'their', 'foo', 'bar'];
33-
const expected = ['there', 'their'];
34-
const actual = getSuggestion(word, dictionary);
35-
36-
expect(expected).toEqual(actual);
37-
});
38-
39-
it('should return correct # of suggestions given the limit argument', () => {
40-
const word = 'theer';
41-
const dictionary = ['there', 'their', 'foo', 'bar'];
42-
const limit = 1;
43-
const expected = 1;
44-
const actual = getSuggestion(word, dictionary, limit).length;
3+
import getSuggestion from '../../../src/util/getSuggestion';
454

46-
expect(expected).toEqual(actual);
47-
});
5+
test('spell check suggestion API', (t) => {
6+
t.deepEqual([], getSuggestion('foo'), 'returns no suggestions given empty word and no dictionary');
7+
8+
t.deepEqual(
9+
getSuggestion('foo'),
10+
[],
11+
'returns no suggestions given real word and no dictionary',
12+
);
13+
14+
t.deepEqual(
15+
getSuggestion('fo', ['foo', 'bar', 'baz']),
16+
['foo'],
17+
'returns correct suggestion given real word and a dictionary',
18+
);
19+
20+
t.deepEqual(
21+
getSuggestion('theer', ['there', 'their', 'foo', 'bar']),
22+
['there', 'their'],
23+
'returns multiple correct suggestions given real word and a dictionary',
24+
);
25+
26+
t.deepEqual(
27+
getSuggestion('theer', ['there', 'their', 'foo', 'bar'], 1),
28+
['there'],
29+
'returns correct # of suggestions given the limit argument',
30+
);
31+
32+
t.end();
4833
});
+80-78
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,85 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import getTabIndex from '../../../src/util/getTabIndex';
34
import IdentifierMock from '../../../__mocks__/IdentifierMock';
45
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
56

6-
describe('getTabIndex', () => {
7-
describe('tabIndex is defined', () => {
8-
describe('as a number ', () => {
9-
describe('zero', () => {
10-
it('should return zero', () => {
11-
expect(getTabIndex(JSXAttributeMock('tabIndex', 0))).toBe(0);
12-
});
13-
});
14-
describe('positive integer', () => {
15-
it('should return the integer', () => {
16-
expect(getTabIndex(JSXAttributeMock('tabIndex', 1))).toBe(1);
17-
});
18-
});
19-
describe('negative integer', () => {
20-
it('should return the integer', () => {
21-
expect(getTabIndex(JSXAttributeMock('tabIndex', -1))).toBe(-1);
22-
});
23-
});
24-
describe('float', () => {
25-
it('should return undefined', () => {
26-
expect(getTabIndex(JSXAttributeMock('tabIndex', 9.1))).toBeUndefined();
27-
});
28-
});
29-
});
30-
describe('as a string', () => {
31-
describe('empty', () => {
32-
it('should return undefined', () => {
33-
expect(getTabIndex(JSXAttributeMock('tabIndex', ''))).toBeUndefined();
34-
});
35-
});
36-
describe('which converts to a number', () => {
37-
it('should return an integer', () => {
38-
expect(getTabIndex(JSXAttributeMock('tabIndex', '0'))).toBe(0);
39-
});
40-
});
41-
describe('which is NaN', () => {
42-
it('should return undefined', () => {
43-
expect(getTabIndex(JSXAttributeMock('tabIndex', '0a'))).toBeUndefined();
44-
});
45-
});
46-
});
47-
describe('as a boolean', () => {
48-
describe('true', () => {
49-
it('should return undefined', () => {
50-
expect(getTabIndex(JSXAttributeMock('tabIndex', true))).toBeUndefined();
51-
});
52-
});
53-
describe('false', () => {
54-
it('should return undefined', () => {
55-
expect(getTabIndex(JSXAttributeMock('tabIndex', false))).toBeUndefined();
56-
});
57-
});
58-
});
59-
describe('as an expression', () => {
60-
describe('function expression', () => {
61-
it('should return the correct type', () => {
62-
const attr = function mockFn() { return 0; };
63-
expect(typeof getTabIndex(JSXAttributeMock('tabIndex', attr))).toEqual('function');
64-
});
65-
});
66-
describe('variable expression', () => {
67-
it('should return the Identifier name', () => {
68-
const name = 'identName';
69-
expect(getTabIndex(JSXAttributeMock(
70-
'tabIndex',
71-
IdentifierMock(name),
72-
true,
73-
))).toEqual(name);
74-
});
75-
});
76-
});
77-
});
78-
describe('tabIndex is not defined', () => {
79-
it('should return undefined', () => {
80-
expect(getTabIndex(JSXAttributeMock('tabIndex', undefined))).toBeUndefined();
81-
});
82-
});
7+
test('getTabIndex', (t) => {
8+
t.equal(
9+
getTabIndex(JSXAttributeMock('tabIndex', 0)),
10+
0,
11+
'tabIndex is defined as zero -> zero',
12+
);
13+
14+
t.equal(
15+
getTabIndex(JSXAttributeMock('tabIndex', 1)),
16+
1,
17+
'tabIndex is defined as a positive integer -> returns it',
18+
);
19+
20+
t.equal(
21+
getTabIndex(JSXAttributeMock('tabIndex', -1)),
22+
-1,
23+
'tabIndex is defined as a negative integer -> returns it',
24+
);
25+
26+
t.equal(
27+
getTabIndex(JSXAttributeMock('tabIndex', '')),
28+
undefined,
29+
'tabIndex is defined as an empty string -> undefined',
30+
);
31+
32+
t.equal(
33+
getTabIndex(JSXAttributeMock('tabIndex', 9.1)),
34+
undefined,
35+
'tabIndex is defined as a float -> undefined',
36+
);
37+
38+
t.equal(
39+
getTabIndex(JSXAttributeMock('tabIndex', '0')),
40+
0,
41+
'tabIndex is defined as a string which converts to a number -> returns the integer',
42+
);
43+
44+
t.equal(
45+
getTabIndex(JSXAttributeMock('tabIndex', '0a')),
46+
undefined,
47+
'tabIndex is defined as a string which is NaN -> returns undefined',
48+
);
49+
50+
t.equal(
51+
getTabIndex(JSXAttributeMock('tabIndex', true)),
52+
undefined,
53+
'tabIndex is defined as true -> returns undefined',
54+
);
55+
t.equal(
56+
getTabIndex(JSXAttributeMock('tabIndex', false)),
57+
undefined,
58+
'tabIndex is defined as false -> returns undefined',
59+
);
60+
61+
t.equal(
62+
typeof getTabIndex(JSXAttributeMock('tabIndex', () => 0)),
63+
'function',
64+
'tabIndex is defined as a function expression -> returns the correct type',
65+
);
66+
67+
const name = 'identName';
68+
t.equal(
69+
getTabIndex(JSXAttributeMock(
70+
'tabIndex',
71+
IdentifierMock(name),
72+
true,
73+
)),
74+
name,
75+
'tabIndex is defined as a variable expression -> returns the Identifier name',
76+
);
77+
78+
t.equal(
79+
getTabIndex(JSXAttributeMock('tabIndex', undefined)),
80+
undefined,
81+
'tabIndex is not defined -> returns undefined',
82+
);
83+
84+
t.end();
8385
});
+135-85
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,157 @@
1-
import expect from 'expect';
1+
import test from 'tape';
22
import { elementType } from 'jsx-ast-utils';
3+
34
import hasAccessibleChild from '../../../src/util/hasAccessibleChild';
45
import JSXElementMock from '../../../__mocks__/JSXElementMock';
56
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
67
import JSXExpressionContainerMock from '../../../__mocks__/JSXExpressionContainerMock';
78

8-
describe('hasAccessibleChild', () => {
9-
describe('has no children and does not set dangerouslySetInnerHTML', () => {
10-
it('returns false', () => {
11-
expect(hasAccessibleChild(JSXElementMock('div', []), elementType)).toBe(false);
12-
});
13-
});
9+
test('hasAccessibleChild', (t) => {
10+
t.equal(
11+
hasAccessibleChild(JSXElementMock('div', []), elementType),
12+
false,
13+
'has no children and does not set dangerouslySetInnerHTML -> false',
14+
);
1415

15-
describe('has no children and sets dangerouslySetInnerHTML', () => {
16-
it('Returns true', () => {
17-
const prop = JSXAttributeMock('dangerouslySetInnerHTML', true);
18-
const element = JSXElementMock('div', [prop], []);
19-
expect(hasAccessibleChild(element, elementType)).toBe(true);
20-
});
21-
});
16+
t.equal(
17+
hasAccessibleChild(
18+
JSXElementMock('div', [JSXAttributeMock('dangerouslySetInnerHTML', true)], []),
19+
elementType,
20+
),
21+
true,
22+
'has no children and sets dangerouslySetInnerHTML -> true',
23+
);
2224

23-
describe('has children', () => {
24-
it('Returns true for a Literal child', () => {
25-
const child = {
26-
type: 'Literal',
27-
value: 'foo',
28-
};
29-
const element = JSXElementMock('div', [], [child]);
30-
expect(hasAccessibleChild(element, elementType)).toBe(true);
31-
});
25+
t.equal(
26+
hasAccessibleChild(
27+
JSXElementMock(
28+
'div',
29+
[],
30+
[{
31+
type: 'Literal',
32+
value: 'foo',
33+
}],
34+
),
35+
elementType,
36+
),
37+
true,
38+
'has children + Literal child -> true',
39+
);
3240

33-
it('Returns true for visible child JSXElement', () => {
34-
const child = JSXElementMock('div', []);
35-
const element = JSXElementMock('div', [], [child]);
36-
expect(hasAccessibleChild(element, elementType)).toBe(true);
37-
});
41+
t.equal(
42+
hasAccessibleChild(
43+
JSXElementMock('div', [], [JSXElementMock('div', [])]),
44+
elementType,
45+
),
46+
true,
47+
'has children + visible JSXElement child -> true',
48+
);
3849

39-
it('Returns true for JSXText Element', () => {
40-
const child = {
50+
t.equal(
51+
hasAccessibleChild(
52+
JSXElementMock('div', [], [{
4153
type: 'JSXText',
4254
value: 'foo',
43-
};
44-
const element = JSXElementMock('div', [], [child]);
45-
expect(hasAccessibleChild(element, elementType)).toBe(true);
46-
});
55+
}]),
56+
elementType,
57+
),
58+
true,
59+
'has children + JSText element -> true',
60+
);
4761

48-
it('Returns false for hidden child JSXElement', () => {
49-
const ariaHiddenAttr = JSXAttributeMock('aria-hidden', true);
50-
const child = JSXElementMock('div', [ariaHiddenAttr]);
51-
const element = JSXElementMock('div', [], [child]);
52-
expect(hasAccessibleChild(element, elementType)).toBe(false);
53-
});
62+
t.equal(
63+
hasAccessibleChild(
64+
JSXElementMock('div', [], [
65+
JSXElementMock('div', [
66+
JSXAttributeMock('aria-hidden', true),
67+
]),
68+
]),
69+
elementType,
70+
),
71+
false,
72+
'has children + hidden child JSXElement -> false',
73+
);
5474

55-
it('Returns true for defined JSXExpressionContainer', () => {
56-
const expression = {
57-
type: 'Identifier',
58-
name: 'foo',
59-
};
60-
const child = JSXExpressionContainerMock(expression);
61-
const element = JSXElementMock('div', [], [child]);
62-
expect(hasAccessibleChild(element, elementType)).toBe(true);
63-
});
75+
t.equal(
76+
hasAccessibleChild(
77+
JSXElementMock('div', [], [
78+
JSXExpressionContainerMock({
79+
type: 'Identifier',
80+
name: 'foo',
81+
}),
82+
]),
83+
elementType,
84+
),
85+
true,
86+
'defined JSXExpressionContainer -> true',
87+
);
6488

65-
it('Returns false for undefined JSXExpressionContainer', () => {
66-
const expression = {
67-
type: 'Identifier',
68-
name: 'undefined',
69-
};
70-
const child = JSXExpressionContainerMock(expression);
71-
const element = JSXElementMock('div', [], [child]);
72-
expect(hasAccessibleChild(element, elementType)).toBe(false);
73-
});
89+
t.equal(
90+
hasAccessibleChild(
91+
JSXElementMock('div', [], [
92+
JSXExpressionContainerMock({
93+
type: 'Identifier',
94+
name: 'undefined',
95+
}),
96+
]),
97+
elementType,
98+
),
99+
false,
100+
'has children + undefined JSXExpressionContainer -> false',
101+
);
74102

75-
it('Returns false for unknown child type', () => {
76-
const child = {
103+
t.equal(
104+
hasAccessibleChild(
105+
JSXElementMock('div', [], [{
77106
type: 'Unknown',
78-
};
79-
const element = JSXElementMock('div', [], [child]);
80-
expect(hasAccessibleChild(element, elementType)).toBe(false);
81-
});
107+
}]),
108+
elementType,
109+
),
110+
false,
111+
'unknown child type -> false',
112+
);
113+
114+
t.equal(
115+
hasAccessibleChild(
116+
JSXElementMock('div', [JSXAttributeMock('children', true)], []),
117+
elementType,
118+
),
119+
true,
120+
'children passed as a prop -> true',
121+
);
82122

83-
it('Returns true with children passed as a prop', () => {
84-
const children = JSXAttributeMock('children', true);
85-
const element = JSXElementMock('div', [children], []);
86-
expect(hasAccessibleChild(element, elementType)).toBe(true);
87-
});
123+
t.equal(
124+
hasAccessibleChild(
125+
JSXElementMock('div', [], [
126+
JSXElementMock('input', [JSXAttributeMock('type', 'hidden')]),
127+
]),
128+
elementType,
129+
),
130+
false,
131+
'has chidren -> hidden child input JSXElement -> false',
132+
);
88133

89-
it('Returns false for hidden child input JSXElement', () => {
90-
const child = JSXElementMock('input', [JSXAttributeMock('type', 'hidden')]);
91-
const element = JSXElementMock('div', [], [child]);
92-
expect(hasAccessibleChild(element, elementType)).toBe(false);
93-
});
134+
t.equal(
135+
hasAccessibleChild(
136+
JSXElementMock('div', [], [
137+
JSXElementMock('CustomInput', [JSXAttributeMock('type', 'hidden')]),
138+
]),
139+
elementType,
140+
),
141+
true,
142+
'has children + custom JSXElement of type hidden -> true',
143+
);
94144

95-
it('Returns true for a custom JSXElement even if type hidden', () => {
96-
const child = JSXElementMock('CustomInput', [JSXAttributeMock('type', 'hidden')]);
97-
const element = JSXElementMock('div', [], [child]);
98-
expect(hasAccessibleChild(element, elementType)).toBe(true);
99-
});
145+
t.equal(
146+
hasAccessibleChild(
147+
JSXElementMock('div', [], [
148+
JSXElementMock('CustomInput', [JSXAttributeMock('type', 'hidden')]),
149+
]),
150+
() => 'input',
151+
),
152+
false,
153+
'custom JSXElement mapped to input if type is hidden -> false',
154+
);
100155

101-
it('Returns false for a custom JSXElement mapped to input if type is hidden', () => {
102-
const child = JSXElementMock('CustomInput', [JSXAttributeMock('type', 'hidden')]);
103-
const element = JSXElementMock('div', [], [child]);
104-
expect(hasAccessibleChild(element, () => 'input')).toBe(false);
105-
});
106-
});
156+
t.end();
107157
});
+81-28
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,87 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import JSXAttributeMock from '../../../../__mocks__/JSXAttributeMock';
34
import getImplicitRoleForInput from '../../../../src/util/implicitRoles/input';
45

5-
describe('isAbstractRole', () => {
6-
it('works for buttons', () => {
7-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'button')])).toBe('button');
8-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'image')])).toBe('button');
9-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'reset')])).toBe('button');
10-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'submit')])).toBe('button');
11-
});
12-
it('works for checkboxes', () => {
13-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'checkbox')])).toBe('checkbox');
14-
});
15-
it('works for radios', () => {
16-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'radio')])).toBe('radio');
17-
});
18-
it('works for ranges', () => {
19-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'range')])).toBe('slider');
20-
});
21-
it('works for textboxes', () => {
22-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'email')])).toBe('textbox');
23-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'password')])).toBe('textbox');
24-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'search')])).toBe('textbox');
25-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'tel')])).toBe('textbox');
26-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'url')])).toBe('textbox');
27-
});
28-
it('works for the default case', () => {
29-
expect(getImplicitRoleForInput([JSXAttributeMock('type', '')])).toBe('textbox');
6+
test('isAbstractRole', (t) => {
7+
t.test('works for buttons', (st) => {
8+
st.equal(
9+
getImplicitRoleForInput([JSXAttributeMock('type', 'button')]),
10+
'button',
11+
);
12+
13+
st.equal(
14+
getImplicitRoleForInput([JSXAttributeMock('type', 'image')]),
15+
'button',
16+
);
17+
18+
st.equal(
19+
getImplicitRoleForInput([JSXAttributeMock('type', 'reset')]),
20+
'button',
21+
);
22+
23+
st.equal(
24+
getImplicitRoleForInput([JSXAttributeMock('type', 'submit')]),
25+
'button',
26+
);
27+
28+
st.end();
3029
});
31-
it('works for the true case', () => {
32-
expect(getImplicitRoleForInput([JSXAttributeMock('type', true)])).toBe('textbox');
30+
31+
t.equal(
32+
getImplicitRoleForInput([JSXAttributeMock('type', 'checkbox')]),
33+
'checkbox',
34+
'works for checkboxes',
35+
);
36+
37+
t.equal(
38+
getImplicitRoleForInput([JSXAttributeMock('type', 'radio')]),
39+
'radio',
40+
'works for radios',
41+
);
42+
43+
t.equal(
44+
getImplicitRoleForInput([JSXAttributeMock('type', 'range')]),
45+
'slider',
46+
'works for ranges',
47+
);
48+
49+
t.test('works for textboxes', (st) => {
50+
st.equal(
51+
getImplicitRoleForInput([JSXAttributeMock('type', 'email')]),
52+
'textbox',
53+
);
54+
st.equal(
55+
getImplicitRoleForInput([JSXAttributeMock('type', 'password')]),
56+
'textbox',
57+
);
58+
st.equal(
59+
getImplicitRoleForInput([JSXAttributeMock('type', 'search')]),
60+
'textbox',
61+
);
62+
st.equal(
63+
getImplicitRoleForInput([JSXAttributeMock('type', 'tel')]),
64+
'textbox',
65+
);
66+
st.equal(
67+
getImplicitRoleForInput([JSXAttributeMock('type', 'url')]),
68+
'textbox',
69+
);
70+
71+
st.end();
3372
});
73+
74+
t.equal(
75+
getImplicitRoleForInput([JSXAttributeMock('type', '')]),
76+
'textbox',
77+
'works for the default case',
78+
);
79+
80+
t.equal(
81+
getImplicitRoleForInput([JSXAttributeMock('type', true)]),
82+
'textbox',
83+
'works for the true case',
84+
);
85+
86+
t.end();
3487
});
+16-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import JSXAttributeMock from '../../../../__mocks__/JSXAttributeMock';
34
import getImplicitRoleForMenu from '../../../../src/util/implicitRoles/menu';
45

5-
describe('isAbstractRole', () => {
6-
it('works for toolbars', () => {
7-
expect(getImplicitRoleForMenu([JSXAttributeMock('type', 'toolbar')])).toBe('toolbar');
8-
});
9-
it('works for non-toolbars', () => {
10-
expect(getImplicitRoleForMenu([JSXAttributeMock('type', '')])).toBe('');
11-
});
6+
test('isAbstractRole', (t) => {
7+
t.equal(
8+
getImplicitRoleForMenu([JSXAttributeMock('type', 'toolbar')]),
9+
'toolbar',
10+
'works for toolbars',
11+
);
12+
13+
t.equal(
14+
getImplicitRoleForMenu([JSXAttributeMock('type', '')]),
15+
'',
16+
'works for non-toolbars',
17+
);
18+
19+
t.end();
1220
});
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import JSXAttributeMock from '../../../../__mocks__/JSXAttributeMock';
34
import getImplicitRoleForMenuitem from '../../../../src/util/implicitRoles/menuitem';
45

5-
describe('isAbstractRole', () => {
6-
it('works for menu items', () => {
7-
expect(getImplicitRoleForMenuitem([JSXAttributeMock('type', 'command')])).toBe('menuitem');
8-
});
9-
it('works for menu item checkboxes', () => {
10-
expect(getImplicitRoleForMenuitem([JSXAttributeMock('type', 'checkbox')])).toBe('menuitemcheckbox');
11-
});
12-
it('works for menu item radios', () => {
13-
expect(getImplicitRoleForMenuitem([JSXAttributeMock('type', 'radio')])).toBe('menuitemradio');
14-
});
15-
it('works for non-toolbars', () => {
16-
expect(getImplicitRoleForMenuitem([JSXAttributeMock('type', '')])).toBe('');
17-
});
18-
it('works for the true case', () => {
19-
expect(getImplicitRoleForMenuitem([JSXAttributeMock('type', true)])).toBe('');
20-
});
6+
test('isAbstractRole', (t) => {
7+
t.equal(
8+
getImplicitRoleForMenuitem([JSXAttributeMock('type', 'command')]),
9+
'menuitem',
10+
'works for menu items',
11+
);
12+
13+
t.equal(
14+
getImplicitRoleForMenuitem([JSXAttributeMock('type', 'checkbox')]),
15+
'menuitemcheckbox',
16+
'works for menu item checkboxes',
17+
);
18+
19+
t.equal(
20+
getImplicitRoleForMenuitem([JSXAttributeMock('type', 'radio')]),
21+
'menuitemradio',
22+
'works for menu item radios',
23+
);
24+
25+
t.equal(
26+
getImplicitRoleForMenuitem([JSXAttributeMock('type', '')]),
27+
'',
28+
'works for non-toolbars',
29+
);
30+
31+
t.equal(
32+
getImplicitRoleForMenuitem([JSXAttributeMock('type', true)]),
33+
'',
34+
'works for the true case',
35+
);
36+
37+
t.end();
2138
});
+30-18
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,51 @@
1-
import expect from 'expect';
1+
import test from 'tape';
22
import { elementType } from 'jsx-ast-utils';
3+
34
import isAbstractRole from '../../../src/util/isAbstractRole';
45
import {
56
genElementSymbol,
67
genAbstractRoleElements,
78
genNonAbstractRoleElements,
89
} from '../../../__mocks__/genInteractives';
910

10-
describe('isAbstractRole', () => {
11-
describe('JSX Components (no tagName)', () => {
12-
it('should NOT identify them as abstract role elements', () => {
13-
expect(isAbstractRole(undefined, []))
14-
.toBe(false);
15-
});
16-
});
17-
describe('elements with an abstract role', () => {
11+
test('isAbstractRole', (t) => {
12+
t.equal(
13+
isAbstractRole(undefined, []),
14+
false,
15+
'does NOT identify JSX Components (no tagName) as abstract role elements',
16+
);
17+
18+
t.test('elements with an abstract role', (st) => {
1819
genAbstractRoleElements().forEach(({ openingElement }) => {
1920
const { attributes } = openingElement;
20-
it(`should identify \`${genElementSymbol(openingElement)}\` as an abstract role element`, () => {
21-
expect(isAbstractRole(
21+
st.equal(
22+
isAbstractRole(
2223
elementType(openingElement),
2324
attributes,
24-
)).toBe(true);
25-
});
25+
),
26+
true,
27+
`identifies \`${genElementSymbol(openingElement)}\` as an abstract role element`,
28+
);
2629
});
30+
31+
st.end();
2732
});
28-
describe('elements with a non-abstract role', () => {
33+
34+
t.test('elements with a non-abstract role', (st) => {
2935
genNonAbstractRoleElements().forEach(({ openingElement }) => {
3036
const { attributes } = openingElement;
31-
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as an abstract role element`, () => {
32-
expect(isAbstractRole(
37+
st.equal(
38+
isAbstractRole(
3339
elementType(openingElement),
3440
attributes,
35-
)).toBe(false);
36-
});
41+
),
42+
false,
43+
`does NOT identify \`${genElementSymbol(openingElement)}\` as an abstract role element`,
44+
);
3745
});
46+
47+
st.end();
3848
});
49+
50+
t.end();
3951
});
+47-46
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,52 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import isContentEditable from '../../../src/util/isContentEditable';
34
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
45

5-
describe('isContentEditable', () => {
6-
describe('HTML5', () => {
7-
describe('content editable', () => {
8-
it('should identify HTML5 contentEditable elements', () => {
9-
const attributes = [
10-
JSXAttributeMock('contentEditable', 'true'),
11-
];
12-
expect(isContentEditable('some tag', attributes))
13-
.toBe(true);
14-
});
15-
});
16-
17-
describe('not content editable', () => {
18-
it('should not identify HTML5 content editable elements with null as the value', () => {
19-
const attributes = [
20-
JSXAttributeMock('contentEditable', null),
21-
];
22-
expect(isContentEditable('some tag', attributes))
23-
.toBe(false);
24-
});
25-
26-
it('should not identify HTML5 content editable elements with undefined as the value', () => {
27-
const attributes = [
28-
JSXAttributeMock('contentEditable', undefined),
29-
];
30-
expect(isContentEditable('some tag', attributes))
31-
.toBe(false);
32-
});
33-
34-
it('should not identify HTML5 content editable elements with true as the value', () => {
35-
const attributes = [
36-
JSXAttributeMock('contentEditable', true),
37-
];
38-
expect(isContentEditable('some tag', attributes))
39-
.toBe(false);
40-
});
41-
42-
it('should not identify HTML5 content editable elements with "false" as the value', () => {
43-
const attributes = [
44-
JSXAttributeMock('contentEditable', 'false'),
45-
];
46-
expect(isContentEditable('some tag', attributes))
47-
.toBe(false);
48-
});
49-
});
6+
test('isContentEditable - HTML5', (t) => {
7+
t.equal(
8+
isContentEditable('some tag', [
9+
JSXAttributeMock('contentEditable', 'true'),
10+
]),
11+
true,
12+
'identifies HTML5 contentEditable elements',
13+
);
14+
15+
t.test('not content editable', (st) => {
16+
st.equal(
17+
isContentEditable('some tag', [
18+
JSXAttributeMock('contentEditable', null),
19+
]),
20+
false,
21+
'does not identify HTML5 content editable elements with null as the value',
22+
);
23+
24+
st.equal(
25+
isContentEditable('some tag', [
26+
JSXAttributeMock('contentEditable', undefined),
27+
]),
28+
false,
29+
'does not identify HTML5 content editable elements with undefined as the value',
30+
);
31+
32+
st.equal(
33+
isContentEditable('some tag', [
34+
JSXAttributeMock('contentEditable', true),
35+
]),
36+
false,
37+
'does not identify HTML5 content editable elements with true as the value',
38+
);
39+
40+
st.equal(
41+
isContentEditable('some tag', [
42+
JSXAttributeMock('contentEditable', 'false'),
43+
]),
44+
false,
45+
'does not identify HTML5 content editable elements with "false" as the value',
46+
);
47+
48+
st.end();
5049
});
50+
51+
t.end();
5152
});
+21-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
1-
import expect from 'expect';
1+
import test from 'tape';
22
import { dom } from 'aria-query';
33
import { elementType } from 'jsx-ast-utils';
4+
45
import isDOMElement from '../../../src/util/isDOMElement';
56
import JSXElementMock from '../../../__mocks__/JSXElementMock';
67

7-
describe('isDOMElement', () => {
8-
describe('DOM elements', () => {
8+
test('isDOMElement', (t) => {
9+
t.test('DOM elements', (st) => {
910
dom.forEach((_, el) => {
10-
it(`should identify ${el} as a DOM element`, () => {
11-
const element = JSXElementMock(el);
12-
expect(isDOMElement(elementType(element.openingElement)))
13-
.toBe(true);
14-
});
15-
});
16-
});
17-
describe('Custom Element', () => {
18-
it('should not identify a custom element', () => {
19-
const element = JSXElementMock('CustomElement');
20-
expect(isDOMElement(element))
21-
.toBe(false);
11+
const element = JSXElementMock(el);
12+
13+
st.equal(
14+
isDOMElement(elementType(element.openingElement)),
15+
true,
16+
`identifies ${el} as a DOM element`,
17+
);
2218
});
19+
20+
st.end();
2321
});
22+
23+
t.equal(
24+
isDOMElement(JSXElementMock('CustomElement')),
25+
false,
26+
'does not identify a custom element',
27+
);
28+
29+
t.end();
2430
});
+82-75
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,88 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import isDisabledElement from '../../../src/util/isDisabledElement';
34
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
45

5-
describe('isDisabledElement', () => {
6-
describe('HTML5', () => {
7-
describe('disabled', () => {
8-
it('should identify HTML5 disabled elements', () => {
9-
const attributes = [
10-
JSXAttributeMock('disabled', 'disabled'),
11-
];
12-
expect(isDisabledElement(attributes))
13-
.toBe(true);
14-
});
15-
});
16-
describe('not disabled', () => {
17-
it('should identify HTML5 disabled elements with null as the value', () => {
18-
const attributes = [
19-
JSXAttributeMock('disabled', null),
20-
];
21-
expect(isDisabledElement(attributes))
22-
.toBe(true);
23-
});
24-
it('should not identify HTML5 disabled elements with undefined as the value', () => {
25-
const attributes = [
26-
JSXAttributeMock('disabled', undefined),
27-
];
28-
expect(isDisabledElement(attributes))
29-
.toBe(false);
30-
});
31-
});
6+
test('isDisabledElement', (t) => {
7+
t.test('HTML5', (st) => {
8+
st.equal(
9+
isDisabledElement([
10+
JSXAttributeMock('disabled', 'disabled'),
11+
]),
12+
true,
13+
'identifies HTML5 disabled elements',
14+
);
15+
16+
st.equal(
17+
isDisabledElement([
18+
JSXAttributeMock('disabled', null),
19+
]),
20+
true,
21+
'identifies HTML5 disabled elements with null as the value',
22+
);
23+
24+
st.equal(
25+
isDisabledElement([
26+
JSXAttributeMock('disabled', undefined),
27+
]),
28+
false,
29+
'does not identify HTML5 disabled elements with undefined as the value',
30+
);
31+
32+
st.end();
3233
});
33-
describe('ARIA', () => {
34-
describe('disabled', () => {
35-
it('should not identify ARIA disabled elements', () => {
36-
const attributes = [
37-
JSXAttributeMock('aria-disabled', 'true'),
38-
];
39-
expect(isDisabledElement(attributes))
40-
.toBe(true);
41-
});
42-
it('should not identify ARIA disabled elements', () => {
43-
const attributes = [
44-
JSXAttributeMock('aria-disabled', true),
45-
];
46-
expect(isDisabledElement(attributes))
47-
.toBe(true);
48-
});
49-
});
50-
describe('not disabled', () => {
51-
it('should not identify ARIA disabled elements', () => {
52-
const attributes = [
53-
JSXAttributeMock('aria-disabled', 'false'),
54-
];
55-
expect(isDisabledElement(attributes))
56-
.toBe(false);
57-
});
58-
it('should not identify ARIA disabled elements', () => {
59-
const attributes = [
60-
JSXAttributeMock('aria-disabled', false),
61-
];
62-
expect(isDisabledElement(attributes))
63-
.toBe(false);
64-
});
65-
it('should not identify ARIA disabled elements with null as the value', () => {
66-
const attributes = [
67-
JSXAttributeMock('aria-disabled', null),
68-
];
69-
expect(isDisabledElement(attributes))
70-
.toBe(false);
71-
});
72-
it('should not identify ARIA disabled elements with undefined as the value', () => {
73-
const attributes = [
74-
JSXAttributeMock('aria-disabled', undefined),
75-
];
76-
expect(isDisabledElement(attributes))
77-
.toBe(false);
78-
});
79-
});
34+
35+
t.test('ARIA', (st) => {
36+
st.equal(
37+
isDisabledElement([
38+
JSXAttributeMock('aria-disabled', 'true'),
39+
]),
40+
true,
41+
'does not identify ARIA disabled elements',
42+
);
43+
44+
st.equal(
45+
isDisabledElement([
46+
JSXAttributeMock('aria-disabled', true),
47+
]),
48+
true,
49+
'does not identify ARIA disabled elements',
50+
);
51+
52+
st.equal(
53+
isDisabledElement([
54+
JSXAttributeMock('aria-disabled', 'false'),
55+
]),
56+
false,
57+
'does not identify ARIA disabled elements',
58+
);
59+
60+
st.equal(
61+
isDisabledElement([
62+
JSXAttributeMock('aria-disabled', false),
63+
]),
64+
false,
65+
'does not identify ARIA disabled elements',
66+
);
67+
68+
st.equal(
69+
isDisabledElement([
70+
JSXAttributeMock('aria-disabled', null),
71+
]),
72+
false,
73+
'does not identify ARIA disabled elements with null as the value',
74+
);
75+
76+
st.equal(
77+
isDisabledElement([
78+
JSXAttributeMock('aria-disabled', undefined),
79+
]),
80+
false,
81+
'does not identify ARIA disabled elements with undefined as the value',
82+
);
83+
84+
st.end();
8085
});
86+
87+
t.end();
8188
});
+65-40
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import expect from 'expect';
1+
import test from 'tape';
22
import { elementType } from 'jsx-ast-utils';
3+
34
import isFocusable from '../../../src/util/isFocusable';
45
import {
56
genElementSymbol,
@@ -12,75 +13,99 @@ function mergeTabIndex(index, attributes) {
1213
return [].concat(attributes, JSXAttributeMock('tabIndex', index));
1314
}
1415

15-
describe('isFocusable', () => {
16-
describe('interactive elements', () => {
16+
test('isFocusable', (t) => {
17+
t.test('interactive elements', (st) => {
1718
genInteractiveElements().forEach(({ openingElement }) => {
18-
it(`should identify \`${genElementSymbol(openingElement)}\` as a focusable element`, () => {
19-
expect(isFocusable(
19+
st.equal(
20+
isFocusable(
2021
elementType(openingElement),
2122
openingElement.attributes,
22-
)).toBe(true);
23-
});
23+
),
24+
true,
25+
`identifies \`${genElementSymbol(openingElement)}\` as a focusable element`,
26+
);
2427

25-
it(`should not identify \`${genElementSymbol(openingElement)}\` with tabIndex of -1 as a focusable element`, () => {
26-
expect(isFocusable(
28+
st.equal(
29+
isFocusable(
2730
elementType(openingElement),
2831
mergeTabIndex(-1, openingElement.attributes),
29-
)).toBe(false);
30-
});
32+
),
33+
false,
34+
`does NOT identify \`${genElementSymbol(openingElement)}\` with tabIndex of -1 as a focusable element`,
35+
);
3136

32-
it(`should identify \`${genElementSymbol(openingElement)}\` with tabIndex of 0 as a focusable element`, () => {
33-
expect(isFocusable(
37+
st.equal(
38+
isFocusable(
3439
elementType(openingElement),
3540
mergeTabIndex(0, openingElement.attributes),
36-
)).toBe(true);
37-
});
41+
),
42+
true,
43+
`identifies \`${genElementSymbol(openingElement)}\` with tabIndex of 0 as a focusable element`,
44+
);
3845

39-
it(`should identify \`${genElementSymbol(openingElement)}\` with tabIndex of 1 as a focusable element`, () => {
40-
expect(isFocusable(
46+
st.equal(
47+
isFocusable(
4148
elementType(openingElement),
4249
mergeTabIndex(1, openingElement.attributes),
43-
)).toBe(true);
44-
});
50+
),
51+
true,
52+
`identifies \`${genElementSymbol(openingElement)}\` with tabIndex of 1 as a focusable element`,
53+
);
4554
});
55+
56+
st.end();
4657
});
4758

48-
describe('non-interactive elements', () => {
59+
t.test('non-interactive elements', (st) => {
4960
genNonInteractiveElements().forEach(({ openingElement }) => {
50-
it(`should not identify \`${genElementSymbol(openingElement)}\` as a focusable element`, () => {
51-
expect(isFocusable(
61+
st.equal(
62+
isFocusable(
5263
elementType(openingElement),
5364
openingElement.attributes,
54-
)).toBe(false);
55-
});
65+
),
66+
false,
67+
`does NOT identify \`${genElementSymbol(openingElement)}\` as a focusable element`,
68+
);
5669

57-
it(`should not identify \`${genElementSymbol(openingElement)}\` with tabIndex of -1 as a focusable element`, () => {
58-
expect(isFocusable(
70+
st.equal(
71+
isFocusable(
5972
elementType(openingElement),
6073
mergeTabIndex(-1, openingElement.attributes),
61-
)).toBe(false);
62-
});
74+
),
75+
false,
76+
`does NOT identify \`${genElementSymbol(openingElement)}\` with tabIndex of -1 as a focusable element`,
77+
);
6378

64-
it(`should identify \`${genElementSymbol(openingElement)}\` with tabIndex of 0 as a focusable element`, () => {
65-
expect(isFocusable(
79+
st.equal(
80+
isFocusable(
6681
elementType(openingElement),
6782
mergeTabIndex(0, openingElement.attributes),
68-
)).toBe(true);
69-
});
83+
),
84+
true,
85+
`identifies \`${genElementSymbol(openingElement)}\` with tabIndex of 0 as a focusable element`,
86+
);
7087

71-
it(`should identify \`${genElementSymbol(openingElement)}\` with tabIndex of 1 as a focusable element`, () => {
72-
expect(isFocusable(
88+
st.equal(
89+
isFocusable(
7390
elementType(openingElement),
7491
mergeTabIndex(1, openingElement.attributes),
75-
)).toBe(true);
76-
});
92+
),
93+
true,
94+
`identifies \`${genElementSymbol(openingElement)}\` with tabIndex of 1 as a focusable element`,
95+
);
7796

78-
it(`should not identify \`${genElementSymbol(openingElement)}\` with tabIndex of 'bogus' as a focusable element`, () => {
79-
expect(isFocusable(
97+
st.equal(
98+
isFocusable(
8099
elementType(openingElement),
81100
mergeTabIndex('bogus', openingElement.attributes),
82-
)).toBe(false);
83-
});
101+
),
102+
false,
103+
`does NOT identify \`${genElementSymbol(openingElement)}\` with tabIndex of 'bogus' as a focusable element`,
104+
);
84105
});
106+
107+
st.end();
85108
});
109+
110+
t.end();
86111
});
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import expect from 'expect';
1+
import test from 'tape';
22
import { elementType } from 'jsx-ast-utils';
3+
34
import isInteractiveElement from '../../../src/util/isInteractiveElement';
45
import JSXElementMock from '../../../__mocks__/JSXElementMock';
56
import {
@@ -11,66 +12,93 @@ import {
1112
genNonInteractiveRoleElements,
1213
} from '../../../__mocks__/genInteractives';
1314

14-
describe('isInteractiveElement', () => {
15-
describe('JSX Components (no tagName)', () => {
16-
it('should identify them as interactive elements', () => {
17-
expect(isInteractiveElement(undefined, []))
18-
.toBe(false);
19-
});
20-
});
21-
describe('interactive elements', () => {
15+
test('isInteractiveElement', (t) => {
16+
t.equal(
17+
isInteractiveElement(undefined, []),
18+
false,
19+
'identifies them as interactive elements',
20+
);
21+
22+
t.test('interactive elements', (st) => {
2223
genInteractiveElements().forEach(({ openingElement }) => {
23-
it(`should identify \`${genElementSymbol(openingElement)}\` as an interactive element`, () => {
24-
expect(isInteractiveElement(
24+
st.equal(
25+
isInteractiveElement(
2526
elementType(openingElement),
2627
openingElement.attributes,
27-
)).toBe(true);
28-
});
28+
),
29+
true,
30+
`identifies \`${genElementSymbol(openingElement)}\` as an interactive element`,
31+
);
2932
});
33+
34+
st.end();
3035
});
31-
describe('interactive role elements', () => {
36+
37+
t.test('interactive role elements', (st) => {
3238
genInteractiveRoleElements().forEach(({ openingElement }) => {
33-
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as an interactive element`, () => {
34-
expect(isInteractiveElement(
39+
st.equal(
40+
isInteractiveElement(
3541
elementType(openingElement),
3642
openingElement.attributes,
37-
)).toBe(false);
38-
});
43+
),
44+
false,
45+
`identifies \`${genElementSymbol(openingElement)}\` as an interactive element`,
46+
);
3947
});
48+
49+
st.end();
4050
});
41-
describe('non-interactive elements', () => {
51+
52+
t.test('non-interactive elements', (st) => {
4253
genNonInteractiveElements().forEach(({ openingElement }) => {
43-
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as an interactive element`, () => {
44-
expect(isInteractiveElement(
54+
st.equal(
55+
isInteractiveElement(
4556
elementType(openingElement),
4657
openingElement.attributes,
47-
)).toBe(false);
48-
});
58+
),
59+
false,
60+
`identifies \`${genElementSymbol(openingElement)}\` as an interactive element`,
61+
);
4962
});
63+
64+
st.end();
5065
});
51-
describe('non-interactive role elements', () => {
66+
67+
t.test('non-interactive role elements', (st) => {
5268
genNonInteractiveRoleElements().forEach(({ openingElement }) => {
53-
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as an interactive element`, () => {
54-
expect(isInteractiveElement(
69+
st.equal(
70+
isInteractiveElement(
5571
elementType(openingElement),
5672
openingElement.attributes,
57-
)).toBe(false);
58-
});
73+
),
74+
false,
75+
`identifies \`${genElementSymbol(openingElement)}\` as an interactive element`,
76+
);
5977
});
78+
79+
st.end();
6080
});
61-
describe('indeterminate elements', () => {
81+
82+
t.test('indeterminate elements', (st) => {
6283
genIndeterminantInteractiveElements().forEach(({ openingElement }) => {
63-
it(`should NOT identify \`${openingElement.name.name}\` as an interactive element`, () => {
64-
expect(isInteractiveElement(
84+
st.equal(
85+
isInteractiveElement(
6586
elementType(openingElement),
6687
openingElement.attributes,
67-
)).toBe(false);
68-
});
69-
});
70-
});
71-
describe('JSX elements', () => {
72-
it('is not interactive', () => {
73-
expect(isInteractiveElement('CustomComponent', JSXElementMock())).toBe(false);
88+
),
89+
false,
90+
`identifies \`${genElementSymbol(openingElement)}\` as an interactive element`,
91+
);
7492
});
93+
94+
st.end();
7595
});
96+
97+
t.equal(
98+
isInteractiveElement('CustomComponent', JSXElementMock()),
99+
false,
100+
'JSX elements are not interactive',
101+
);
102+
103+
t.end();
76104
});
+38-23
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,59 @@
1-
import expect from 'expect';
1+
import test from 'tape';
22
import { elementType } from 'jsx-ast-utils';
3+
34
import isInteractiveRole from '../../../src/util/isInteractiveRole';
45
import {
56
genElementSymbol,
67
genInteractiveRoleElements,
78
genNonInteractiveRoleElements,
89
} from '../../../__mocks__/genInteractives';
910

10-
describe('isInteractiveRole', () => {
11-
describe('JSX Components (no tagName)', () => {
12-
it('should identify them as interactive role elements', () => {
13-
expect(isInteractiveRole(undefined, []))
14-
.toBe(false);
15-
});
16-
});
17-
describe('elements with a non-interactive role', () => {
11+
test('isInteractiveRole', (t) => {
12+
t.equal(
13+
isInteractiveRole(undefined, []),
14+
false,
15+
'identifies JSX Components (no tagName) as interactive role elements',
16+
);
17+
18+
t.test('elements with a non-interactive role', (st) => {
1819
genNonInteractiveRoleElements().forEach(({ openingElement }) => {
1920
const { attributes } = openingElement;
20-
it(`should not identify \`${genElementSymbol(openingElement)}\` as an interactive role element`, () => {
21-
expect(isInteractiveRole(
21+
22+
st.equal(
23+
isInteractiveRole(
2224
elementType(openingElement),
2325
attributes,
24-
)).toBe(false);
25-
});
26-
});
27-
});
28-
describe('elements without a role', () => {
29-
it('should not identify them as interactive role elements', () => {
30-
expect(isInteractiveRole('div', [])).toBe(false);
26+
),
27+
false,
28+
`does NOT identify \`${genElementSymbol(openingElement)}\` as an interactive role element`,
29+
);
3130
});
31+
32+
st.end();
3233
});
33-
describe('elements with an interactive role', () => {
34+
35+
t.equal(
36+
isInteractiveRole('div', []),
37+
false,
38+
'does NOT identify elements without a role as interactive role elements',
39+
);
40+
41+
t.test('elements with an interactive role', (st) => {
3442
genInteractiveRoleElements().forEach(({ openingElement }) => {
3543
const { attributes } = openingElement;
36-
it(`should identify \`${genElementSymbol(openingElement)}\` as an interactive role element`, () => {
37-
expect(isInteractiveRole(
44+
45+
st.equal(
46+
isInteractiveRole(
3847
elementType(openingElement),
3948
attributes,
40-
)).toBe(true);
41-
});
49+
),
50+
true,
51+
`identifies \`${genElementSymbol(openingElement)}\` as an interactive role element`,
52+
);
4253
});
54+
55+
st.end();
4356
});
57+
58+
t.end();
4459
});
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import expect from 'expect';
1+
import test from 'tape';
22
import { elementType } from 'jsx-ast-utils';
3+
34
import isNonInteractiveElement from '../../../src/util/isNonInteractiveElement';
45
import {
56
genElementSymbol,
@@ -10,61 +11,87 @@ import {
1011
genNonInteractiveRoleElements,
1112
} from '../../../__mocks__/genInteractives';
1213

13-
describe('isNonInteractiveElement', () => {
14-
describe('JSX Components (no tagName)', () => {
15-
it('should identify them as interactive elements', () => {
16-
expect(isNonInteractiveElement(undefined, []))
17-
.toBe(false);
18-
});
19-
});
20-
describe('non-interactive elements', () => {
14+
test('isNonInteractiveElement', (t) => {
15+
t.equal(
16+
isNonInteractiveElement(undefined, []),
17+
false,
18+
'identifies JSX Components (no tagName) as non-interactive elements',
19+
);
20+
21+
t.test('non-interactive elements', (st) => {
2122
genNonInteractiveElements().forEach(({ openingElement }) => {
22-
it(`should identify \`${genElementSymbol(openingElement)}\` as a non-interactive element`, () => {
23-
expect(isNonInteractiveElement(
23+
st.equal(
24+
isNonInteractiveElement(
2425
elementType(openingElement),
2526
openingElement.attributes,
26-
)).toBe(true);
27-
});
27+
),
28+
true,
29+
`identifies \`${genElementSymbol(openingElement)}\` as a non-interactive element`,
30+
);
2831
});
32+
33+
st.end();
2934
});
30-
describe('non-interactive role elements', () => {
35+
36+
t.test('non-interactive role elements', (st) => {
3137
genNonInteractiveRoleElements().forEach(({ openingElement }) => {
32-
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as a non-interactive element`, () => {
33-
expect(isNonInteractiveElement(
38+
st.equal(
39+
isNonInteractiveElement(
3440
elementType(openingElement),
3541
openingElement.attributes,
36-
)).toBe(false);
37-
});
42+
),
43+
false,
44+
`identifies \`${genElementSymbol(openingElement)}\` as a non-interactive element`,
45+
);
3846
});
47+
48+
st.end();
3949
});
40-
describe('interactive elements', () => {
50+
51+
t.test('interactive elements', (st) => {
4152
genInteractiveElements().forEach(({ openingElement }) => {
42-
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as a non-interactive element`, () => {
43-
expect(isNonInteractiveElement(
53+
st.equal(
54+
isNonInteractiveElement(
4455
elementType(openingElement),
4556
openingElement.attributes,
46-
)).toBe(false);
47-
});
57+
),
58+
false,
59+
`identifies \`${genElementSymbol(openingElement)}\` as a non-interactive element`,
60+
);
4861
});
62+
63+
st.end();
4964
});
50-
describe('interactive role elements', () => {
65+
66+
t.test('interactive role elements', (st) => {
5167
genInteractiveRoleElements().forEach(({ openingElement }) => {
52-
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as a non-interactive element`, () => {
53-
expect(isNonInteractiveElement(
68+
st.equal(
69+
isNonInteractiveElement(
5470
elementType(openingElement),
5571
openingElement.attributes,
56-
)).toBe(false);
57-
});
72+
),
73+
false,
74+
`identifies \`${genElementSymbol(openingElement)}\` as a non-interactive element`,
75+
);
5876
});
77+
78+
st.end();
5979
});
60-
describe('indeterminate elements', () => {
80+
81+
t.test('indeterminate elements', (st) => {
6182
genIndeterminantInteractiveElements().forEach(({ openingElement }) => {
62-
it(`should NOT identify \`${openingElement.name.name}\` as a non-interactive element`, () => {
63-
expect(isNonInteractiveElement(
83+
st.equal(
84+
isNonInteractiveElement(
6485
elementType(openingElement),
6586
openingElement.attributes,
66-
)).toBe(false);
67-
});
87+
),
88+
false,
89+
`identifies \`${genElementSymbol(openingElement)}\` as a non-interactive element`,
90+
);
6891
});
92+
93+
st.end();
6994
});
95+
96+
t.end();
7097
});
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,59 @@
1-
import expect from 'expect';
1+
import test from 'tape';
22
import { elementType } from 'jsx-ast-utils';
3+
34
import isNonInteractiveRole from '../../../src/util/isNonInteractiveRole';
45
import {
56
genElementSymbol,
67
genInteractiveRoleElements,
78
genNonInteractiveRoleElements,
89
} from '../../../__mocks__/genInteractives';
910

10-
describe('isNonInteractiveRole', () => {
11-
describe('JSX Components (no tagName)', () => {
12-
it('should identify them as interactive role elements', () => {
13-
expect(isNonInteractiveRole(undefined, []))
14-
.toBe(false);
15-
});
16-
});
17-
describe('elements with a non-interactive role', () => {
11+
test('isNonInteractiveRole', (t) => {
12+
t.equal(
13+
isNonInteractiveRole(undefined, []),
14+
false,
15+
'identifies JSX Components (no tagName) as non-interactive elements',
16+
);
17+
18+
t.test('elements with a non-interactive role', (st) => {
1819
genNonInteractiveRoleElements().forEach(({ openingElement }) => {
1920
const { attributes } = openingElement;
20-
it(`should identify \`${genElementSymbol(openingElement)}\` as non-interactive role element`, () => {
21-
expect(isNonInteractiveRole(
21+
22+
st.equal(
23+
isNonInteractiveRole(
2224
elementType(openingElement),
2325
attributes,
24-
)).toBe(true);
25-
});
26-
});
27-
});
28-
describe('elements without a role', () => {
29-
it('should not identify them as non-interactive role elements', () => {
30-
expect(isNonInteractiveRole('div', [])).toBe(false);
26+
),
27+
true,
28+
`identifies \`${genElementSymbol(openingElement)}\` as a non-interactive role element`,
29+
);
3130
});
31+
32+
st.end();
3233
});
33-
describe('elements with an interactive role', () => {
34+
35+
t.equal(
36+
isNonInteractiveRole('div', []),
37+
false,
38+
'does NOT identify elements without a role as non-interactive role elements',
39+
);
40+
41+
t.test('elements with an interactive role', (st) => {
3442
genInteractiveRoleElements().forEach(({ openingElement }) => {
3543
const { attributes } = openingElement;
36-
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as a non-interactive role element`, () => {
37-
expect(isNonInteractiveRole(
44+
45+
st.equal(
46+
isNonInteractiveRole(
3847
elementType(openingElement),
3948
attributes,
40-
)).toBe(false);
41-
});
49+
),
50+
false,
51+
`does NOT identify \`${genElementSymbol(openingElement)}\` as a non-interactive role element`,
52+
);
4253
});
54+
55+
st.end();
4356
});
57+
58+
t.end();
4459
});
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import isNonLiteralProperty from '../../../src/util/isNonLiteralProperty';
34
import IdentifierMock from '../../../__mocks__/IdentifierMock';
45
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
@@ -10,35 +11,42 @@ const theProp = 'theProp';
1011

1112
const spread = JSXSpreadAttributeMock('theSpread');
1213

13-
describe('isNonLiteralProperty', () => {
14-
describe('elements without the property', () => {
15-
it('should not identify them as non-literal role elements', () => {
16-
expect(isNonLiteralProperty([], theProp)).toBe(false);
17-
});
18-
});
19-
describe('elements with a literal property', () => {
20-
it('should not identify them as non-literal role elements without spread operator', () => {
21-
expect(isNonLiteralProperty([JSXAttributeMock(theProp, LiteralMock('theRole'))], theProp)).toBe(false);
22-
});
23-
it('should not identify them as non-literal role elements with spread operator', () => {
24-
expect(isNonLiteralProperty([spread, JSXAttributeMock(theProp, LiteralMock('theRole'))], theProp)).toBe(false);
25-
});
26-
});
27-
describe('elements with a JSXText property', () => {
28-
it('should not identify them as non-literal role elements', () => {
29-
expect(isNonLiteralProperty([JSXAttributeMock(theProp, JSXTextMock('theRole'))], theProp)).toBe(false);
30-
});
31-
});
32-
describe('elements with a property of undefined', () => {
33-
it('should not identify them as non-literal role elements', () => {
34-
const undefinedExpression = IdentifierMock('undefined');
35-
expect(isNonLiteralProperty([JSXAttributeMock(theProp, undefinedExpression)], theProp)).toBe(false);
36-
});
37-
});
38-
describe('elements with a expression property', () => {
39-
it('should identify them as non-literal role elements', () => {
40-
const identifierExpression = IdentifierMock('theIdentifier');
41-
expect(isNonLiteralProperty([JSXAttributeMock(theProp, identifierExpression)], theProp)).toBe(true);
42-
});
43-
});
14+
test('isNonLiteralProperty', (t) => {
15+
t.equal(
16+
isNonLiteralProperty([], theProp),
17+
false,
18+
'does not identify them as non-literal role elements',
19+
);
20+
21+
t.equal(
22+
isNonLiteralProperty([JSXAttributeMock(theProp, LiteralMock('theRole'))], theProp),
23+
false,
24+
'does not identify elements with a literal property as non-literal role elements without spread operator',
25+
);
26+
27+
t.equal(
28+
isNonLiteralProperty([spread, JSXAttributeMock(theProp, LiteralMock('theRole'))], theProp),
29+
false,
30+
'does not identify elements with a literal property as non-literal role elements with spread operator',
31+
);
32+
33+
t.equal(
34+
isNonLiteralProperty([JSXAttributeMock(theProp, JSXTextMock('theRole'))], theProp),
35+
false,
36+
'identifies elements with a JSXText property as non-literal role elements',
37+
);
38+
39+
t.equal(
40+
isNonLiteralProperty([JSXAttributeMock(theProp, IdentifierMock('undefined'))], theProp),
41+
false,
42+
'does not identify elements with a property of undefined as non-literal role elements',
43+
);
44+
45+
t.equal(
46+
isNonLiteralProperty([JSXAttributeMock(theProp, IdentifierMock('theIdentifier'))], theProp),
47+
true,
48+
'identifies elements with an expression property as non-literal role elements',
49+
);
50+
51+
t.end();
4452
});
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,55 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import isSemanticRoleElement from '../../../src/util/isSemanticRoleElement';
34
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
45

5-
describe('isSemanticRoleElement', () => {
6-
it('should identify semantic role elements', () => {
7-
expect(isSemanticRoleElement('input', [
6+
test('isSemanticRoleElement', (t) => {
7+
t.equal(
8+
isSemanticRoleElement('input', [
89
JSXAttributeMock('type', 'checkbox'),
910
JSXAttributeMock('role', 'switch'),
10-
])).toBe(true);
11-
});
12-
it('should reject non-semantic role elements', () => {
13-
expect(isSemanticRoleElement('input', [
14-
JSXAttributeMock('type', 'radio'),
15-
JSXAttributeMock('role', 'switch'),
16-
])).toBe(false);
17-
expect(isSemanticRoleElement('input', [
18-
JSXAttributeMock('type', 'text'),
19-
JSXAttributeMock('role', 'combobox'),
20-
])).toBe(false);
21-
expect(isSemanticRoleElement('button', [
22-
JSXAttributeMock('role', 'switch'),
23-
JSXAttributeMock('aria-pressed', 'true'),
24-
])).toBe(false);
25-
expect(isSemanticRoleElement('input', [
26-
JSXAttributeMock('role', 'switch'),
27-
])).toBe(false);
11+
]),
12+
true,
13+
'identifies semantic role elements',
14+
);
15+
16+
t.test('rejects non-semantics role elements', (st) => {
17+
st.equal(
18+
isSemanticRoleElement('input', [
19+
JSXAttributeMock('type', 'radio'),
20+
JSXAttributeMock('role', 'switch'),
21+
]),
22+
false,
23+
);
24+
25+
st.equal(
26+
isSemanticRoleElement('input', [
27+
JSXAttributeMock('type', 'text'),
28+
JSXAttributeMock('role', 'combobox'),
29+
]),
30+
false,
31+
);
32+
33+
st.equal(
34+
isSemanticRoleElement('button', [
35+
JSXAttributeMock('role', 'switch'),
36+
JSXAttributeMock('aria-pressed', 'true'),
37+
]),
38+
false,
39+
);
40+
41+
st.equal(
42+
isSemanticRoleElement('input', [
43+
JSXAttributeMock('role', 'switch'),
44+
]),
45+
false,
46+
);
47+
48+
st.end();
2849
});
29-
it('should not throw on JSXSpreadAttribute', () => {
30-
expect(() => {
50+
51+
t.doesNotThrow(
52+
() => {
3153
isSemanticRoleElement('input', [
3254
JSXAttributeMock('type', 'checkbox'),
3355
JSXAttributeMock('role', 'checkbox'),
@@ -42,6 +64,9 @@ describe('isSemanticRoleElement', () => {
4264
},
4365
},
4466
]);
45-
}).not.toThrow();
46-
});
67+
},
68+
'does not throw on JSXSpreadAttribute',
69+
);
70+
71+
t.end();
4772
});
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,87 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import mayContainChildComponent from '../../../src/util/mayContainChildComponent';
34
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
45
import JSXElementMock from '../../../__mocks__/JSXElementMock';
56
import JSXExpressionContainerMock from '../../../__mocks__/JSXExpressionContainerMock';
67

7-
describe('mayContainChildComponent', () => {
8-
describe('no FancyComponent', () => {
9-
it('should return false', () => {
10-
expect(mayContainChildComponent(
8+
test('mayContainChildComponent', (t) => {
9+
t.equal(
10+
mayContainChildComponent(
11+
JSXElementMock('div', [], [
1112
JSXElementMock('div', [], [
12-
JSXElementMock('div', [], [
13+
JSXElementMock('span', [], []),
14+
JSXElementMock('span', [], [
1315
JSXElementMock('span', [], []),
1416
JSXElementMock('span', [], [
1517
JSXElementMock('span', [], []),
16-
JSXElementMock('span', [], [
17-
JSXElementMock('span', [], []),
18-
]),
1918
]),
2019
]),
21-
JSXElementMock('span', [], []),
22-
JSXElementMock('img', [
23-
JSXAttributeMock('src', 'some/path'),
24-
]),
2520
]),
26-
'FancyComponent',
27-
5,
28-
)).toBe(false);
29-
});
30-
});
31-
describe('contains an indicated component', () => {
32-
it('should return true', () => {
33-
expect(mayContainChildComponent(
21+
JSXElementMock('span', [], []),
22+
JSXElementMock('img', [
23+
JSXAttributeMock('src', 'some/path'),
24+
]),
25+
]),
26+
'FancyComponent',
27+
5,
28+
),
29+
false,
30+
'no FancyComponent returns false',
31+
);
32+
33+
t.test('contains an indicated component', (st) => {
34+
st.equal(
35+
mayContainChildComponent(
3436
JSXElementMock('div', [], [
3537
JSXElementMock('input'),
3638
]),
3739
'input',
38-
)).toBe(true);
39-
});
40-
it('should return true', () => {
41-
expect(mayContainChildComponent(
40+
),
41+
true,
42+
'returns true',
43+
);
44+
45+
st.equal(
46+
mayContainChildComponent(
4247
JSXElementMock('div', [], [
4348
JSXElementMock('FancyComponent'),
4449
]),
4550
'FancyComponent',
46-
)).toBe(true);
47-
});
48-
it('FancyComponent is outside of default depth, should return false', () => {
49-
expect(mayContainChildComponent(
51+
),
52+
true,
53+
'returns true',
54+
);
55+
56+
st.equal(
57+
mayContainChildComponent(
5058
JSXElementMock('div', [], [
5159
JSXElementMock('div', [], [
5260
JSXElementMock('FancyComponent'),
5361
]),
5462
]),
5563
'FancyComponent',
56-
)).toBe(false);
57-
});
58-
it('FancyComponent is inside of custom depth, should return true', () => {
59-
expect(mayContainChildComponent(
64+
),
65+
false,
66+
'FancyComponent is outside of default depth, should return false',
67+
);
68+
69+
st.equal(
70+
mayContainChildComponent(
6071
JSXElementMock('div', [], [
6172
JSXElementMock('div', [], [
6273
JSXElementMock('FancyComponent'),
6374
]),
6475
]),
6576
'FancyComponent',
6677
2,
67-
)).toBe(true);
68-
});
69-
it('deep nesting, should return true', () => {
70-
expect(mayContainChildComponent(
78+
),
79+
true,
80+
'FancyComponent is inside of custom depth, should return true',
81+
);
82+
83+
st.equal(
84+
mayContainChildComponent(
7185
JSXElementMock('div', [], [
7286
JSXElementMock('div', [], [
7387
JSXElementMock('span', [], []),
@@ -89,90 +103,117 @@ describe('mayContainChildComponent', () => {
89103
]),
90104
'FancyComponent',
91105
6,
92-
)).toBe(true);
93-
});
94-
});
95-
describe('Intederminate situations', () => {
96-
describe('expression container children', () => {
97-
it('should return true', () => {
98-
expect(mayContainChildComponent(
99-
JSXElementMock('div', [], [
100-
JSXExpressionContainerMock('mysteryBox'),
101-
]),
102-
'FancyComponent',
103-
)).toBe(true);
104-
});
105-
});
106+
),
107+
true,
108+
'deep nesting, returns true',
109+
);
110+
111+
st.end();
106112
});
107113

108-
describe('Glob name matching', () => {
109-
describe('component name contains question mark ? - match any single character', () => {
110-
it('should return true', () => {
111-
expect(mayContainChildComponent(
112-
JSXElementMock('div', [], [
113-
JSXElementMock('FancyComponent'),
114-
]),
115-
'Fanc?Co??onent',
116-
)).toBe(true);
117-
});
118-
it('should return false', () => {
119-
expect(mayContainChildComponent(
120-
JSXElementMock('div', [], [
121-
JSXElementMock('FancyComponent'),
122-
]),
123-
'FancyComponent?',
124-
)).toBe(false);
125-
});
126-
});
114+
t.equal(
115+
mayContainChildComponent(
116+
JSXElementMock('div', [], [
117+
JSXExpressionContainerMock('mysteryBox'),
118+
]),
119+
'FancyComponent',
120+
),
121+
true,
122+
'Intederminate situations + expression container children - returns true',
123+
);
124+
125+
t.test('Glob name matching - component name contains question mark ? - match any single character', (st) => {
126+
st.equal(
127+
mayContainChildComponent(
128+
JSXElementMock('div', [], [
129+
JSXElementMock('FancyComponent'),
130+
]),
131+
'Fanc?Co??onent',
132+
),
133+
true,
134+
'returns true',
135+
);
127136

128-
describe('component name contains asterisk * - match zero or more characters', () => {
129-
it('should return true', () => {
130-
expect(mayContainChildComponent(
137+
st.equal(
138+
mayContainChildComponent(
139+
JSXElementMock('div', [], [
140+
JSXElementMock('FancyComponent'),
141+
]),
142+
'FancyComponent?',
143+
),
144+
false,
145+
'returns false',
146+
);
147+
148+
st.test('component name contains asterisk * - match zero or more characters', (s2t) => {
149+
s2t.equal(
150+
mayContainChildComponent(
131151
JSXElementMock('div', [], [
132152
JSXElementMock('FancyComponent'),
133153
]),
134154
'Fancy*',
135-
)).toBe(true);
136-
});
137-
it('should return true', () => {
138-
expect(mayContainChildComponent(
155+
),
156+
true,
157+
'returns true',
158+
);
159+
160+
s2t.equal(
161+
mayContainChildComponent(
139162
JSXElementMock('div', [], [
140163
JSXElementMock('FancyComponent'),
141164
]),
142165
'*Component',
143-
)).toBe(true);
144-
});
145-
it('should return true', () => {
146-
expect(mayContainChildComponent(
166+
),
167+
true,
168+
'returns true',
169+
);
170+
171+
s2t.equal(
172+
mayContainChildComponent(
147173
JSXElementMock('div', [], [
148174
JSXElementMock('FancyComponent'),
149175
]),
150176
'Fancy*C*t',
151-
)).toBe(true);
152-
});
177+
),
178+
true,
179+
'returns true',
180+
);
181+
182+
s2t.end();
153183
});
184+
185+
st.end();
154186
});
155187

156-
describe('using a custom elementType function', () => {
157-
it('should return true when the custom elementType returns the proper name', () => {
158-
expect(mayContainChildComponent(
188+
t.test('using a custom elementType function', (st) => {
189+
st.equal(
190+
mayContainChildComponent(
159191
JSXElementMock('div', [], [
160192
JSXElementMock('CustomInput'),
161193
]),
162194
'input',
163195
2,
164196
() => 'input',
165-
)).toBe(true);
166-
});
167-
it('should return false when the custom elementType returns a wrong name', () => {
168-
expect(mayContainChildComponent(
197+
),
198+
true,
199+
'returns true when the custom elementType returns the proper name',
200+
);
201+
202+
st.equal(
203+
mayContainChildComponent(
169204
JSXElementMock('div', [], [
170205
JSXElementMock('CustomInput'),
171206
]),
172207
'input',
173208
2,
174209
() => 'button',
175-
)).toBe(false);
176-
});
210+
),
211+
false,
212+
'returns false when the custom elementType returns a wrong name',
213+
);
214+
215+
st.end();
177216
});
217+
218+
t.end();
178219
});
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,130 @@
1-
import expect from 'expect';
1+
import test from 'tape';
22
import { elementType } from 'jsx-ast-utils';
3+
34
import getAccessibleChildText from '../../../src/util/getAccessibleChildText';
45
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
56
import JSXElementMock from '../../../__mocks__/JSXElementMock';
67

7-
describe('getAccessibleChildText', () => {
8-
it('returns the aria-label when present', () => {
9-
expect(getAccessibleChildText(JSXElementMock(
8+
test('getAccessibleChildText', (t) => {
9+
t.equal(
10+
getAccessibleChildText(JSXElementMock(
1011
'a',
1112
[JSXAttributeMock('aria-label', 'foo')],
12-
), elementType)).toBe('foo');
13-
});
13+
), elementType),
14+
'foo',
15+
'returns the aria-label when present',
16+
);
1417

15-
it('returns the aria-label instead of children', () => {
16-
expect(getAccessibleChildText(JSXElementMock(
18+
t.equal(
19+
getAccessibleChildText(JSXElementMock(
1720
'a',
1821
[JSXAttributeMock('aria-label', 'foo')],
1922
[{ type: 'JSXText', value: 'bar' }],
20-
), elementType)).toBe('foo');
21-
});
23+
), elementType),
24+
'foo',
25+
'returns the aria-label instead of children',
26+
);
2227

23-
it('skips elements with aria-hidden=true', () => {
24-
expect(getAccessibleChildText(JSXElementMock(
28+
t.equal(
29+
getAccessibleChildText(JSXElementMock(
2530
'a',
2631
[JSXAttributeMock('aria-hidden', 'true')],
27-
), elementType)).toBe('');
28-
});
32+
), elementType),
33+
'',
34+
'skips elements with aria-hidden=true',
35+
);
2936

30-
it('returns literal value for JSXText child', () => {
31-
expect(getAccessibleChildText(JSXElementMock(
37+
t.equal(
38+
getAccessibleChildText(JSXElementMock(
3239
'a',
3340
[],
3441
[{ type: 'JSXText', value: 'bar' }],
35-
), elementType)).toBe('bar');
36-
});
42+
), elementType),
43+
'bar',
44+
'returns literal value for JSXText child',
45+
);
3746

38-
it('returns alt text for img child', () => {
39-
expect(getAccessibleChildText(JSXElementMock(
47+
t.equal(
48+
getAccessibleChildText(JSXElementMock(
4049
'a',
4150
[],
4251
[JSXElementMock('img', [
4352
JSXAttributeMock('src', 'some/path'),
4453
JSXAttributeMock('alt', 'a sensible label'),
4554
])],
46-
), elementType)).toBe('a sensible label');
47-
});
55+
), elementType),
56+
'a sensible label',
57+
'returns alt text for img child',
58+
);
4859

49-
it('returns blank when alt tag is used on arbitrary element', () => {
50-
expect(getAccessibleChildText(JSXElementMock(
60+
t.equal(
61+
getAccessibleChildText(JSXElementMock(
5162
'a',
5263
[],
5364
[JSXElementMock('span', [
5465
JSXAttributeMock('alt', 'a sensible label'),
5566
])],
56-
), elementType)).toBe('');
57-
});
67+
), elementType),
68+
'',
69+
'returns blank when alt tag is used on arbitrary element',
70+
);
5871

59-
it('returns literal value for JSXText child', () => {
60-
expect(getAccessibleChildText(JSXElementMock(
72+
t.equal(
73+
getAccessibleChildText(JSXElementMock(
6174
'a',
6275
[],
6376
[{ type: 'Literal', value: 'bar' }],
64-
), elementType)).toBe('bar');
65-
});
77+
), elementType),
78+
'bar',
79+
'returns literal value for JSXText child',
80+
);
6681

67-
it('returns trimmed literal value for JSXText child', () => {
68-
expect(getAccessibleChildText(JSXElementMock(
82+
t.equal(
83+
getAccessibleChildText(JSXElementMock(
6984
'a',
7085
[],
7186
[{ type: 'Literal', value: ' bar ' }],
72-
), elementType)).toBe('bar');
73-
});
87+
), elementType),
88+
'bar',
89+
'returns trimmed literal value for JSXText child',
90+
);
7491

75-
it('returns space-collapsed literal value for JSXText child', () => {
76-
expect(getAccessibleChildText(JSXElementMock(
92+
t.equal(
93+
getAccessibleChildText(JSXElementMock(
7794
'a',
7895
[],
7996
[{ type: 'Literal', value: 'foo bar' }],
80-
), elementType)).toBe('foo bar');
81-
});
97+
), elementType),
98+
'foo bar',
99+
'returns space-collapsed literal value for JSXText child',
100+
);
82101

83-
it('returns punctuation-stripped literal value for JSXText child', () => {
84-
expect(getAccessibleChildText(JSXElementMock(
102+
t.equal(
103+
getAccessibleChildText(JSXElementMock(
85104
'a',
86105
[],
87106
[{ type: 'Literal', value: 'foo, bar. baz? foo; bar:' }],
88-
), elementType)).toBe('foo bar baz foo bar');
89-
});
107+
), elementType),
108+
'foo bar baz foo bar',
109+
'returns punctuation-stripped literal value for JSXText child',
110+
);
90111

91-
it('returns recursive value for JSXElement child', () => {
92-
expect(getAccessibleChildText(JSXElementMock(
112+
t.equal(
113+
getAccessibleChildText(JSXElementMock(
93114
'a',
94115
[],
95116
[JSXElementMock(
96117
'span',
97118
[],
98119
[{ type: 'Literal', value: 'bar' }],
99120
)],
100-
), elementType)).toBe('bar');
101-
});
121+
), elementType),
122+
'bar',
123+
'returns recursive value for JSXElement child',
124+
);
102125

103-
it('skips children with aria-hidden-true', () => {
104-
expect(getAccessibleChildText(JSXElementMock(
126+
t.equal(
127+
getAccessibleChildText(JSXElementMock(
105128
'a',
106129
[],
107130
[JSXElementMock(
@@ -112,30 +135,40 @@ describe('getAccessibleChildText', () => {
112135
[JSXAttributeMock('aria-hidden', 'true')],
113136
)],
114137
)],
115-
), elementType)).toBe('');
116-
});
138+
), elementType),
139+
'',
140+
'skips children with aria-hidden-true',
141+
);
117142

118-
it('joins multiple children properly - no spacing', () => {
119-
expect(getAccessibleChildText(JSXElementMock(
143+
t.equal(
144+
getAccessibleChildText(JSXElementMock(
120145
'a',
121146
[],
122147
[{ type: 'Literal', value: 'foo' }, { type: 'Literal', value: 'bar' }],
123-
), elementType)).toBe('foo bar');
124-
});
148+
), elementType),
149+
'foo bar',
150+
'joins multiple children properly - no spacing',
151+
);
125152

126-
it('joins multiple children properly - with spacing', () => {
127-
expect(getAccessibleChildText(JSXElementMock(
153+
t.equal(
154+
getAccessibleChildText(JSXElementMock(
128155
'a',
129156
[],
130157
[{ type: 'Literal', value: ' foo ' }, { type: 'Literal', value: ' bar ' }],
131-
), elementType)).toBe('foo bar');
132-
});
158+
), elementType),
159+
'foo bar',
160+
'joins multiple children properly - with spacing',
161+
);
133162

134-
it('skips unknown elements', () => {
135-
expect(getAccessibleChildText(JSXElementMock(
163+
t.equal(
164+
getAccessibleChildText(JSXElementMock(
136165
'a',
137166
[],
138167
[{ type: 'Literal', value: 'foo' }, { type: 'Unknown' }, { type: 'Literal', value: 'bar' }],
139-
), elementType)).toBe('foo bar');
140-
});
168+
), elementType),
169+
'foo bar',
170+
'skips unknown elements',
171+
);
172+
173+
t.end();
141174
});
+66-66
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,71 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import getComputedRole from '../../../src/util/getComputedRole';
34
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
45

5-
describe('getComputedRole', () => {
6-
describe('explicit role', () => {
7-
describe('valid role', () => {
8-
it('should return the role', () => {
9-
expect(getComputedRole(
10-
'div',
11-
[JSXAttributeMock('role', 'button')],
12-
)).toBe('button');
13-
});
14-
});
15-
describe('invalid role', () => {
16-
describe('has implicit', () => {
17-
it('should return the implicit role', () => {
18-
expect(getComputedRole(
19-
'li',
20-
[JSXAttributeMock('role', 'beeswax')],
21-
)).toBe('listitem');
22-
});
23-
});
24-
describe('lacks implicit', () => {
25-
it('should return null', () => {
26-
expect(getComputedRole(
27-
'div',
28-
[JSXAttributeMock('role', 'beeswax')],
29-
)).toBeNull();
30-
});
31-
});
32-
});
6+
test('getComputedRole', (t) => {
7+
t.equal(
8+
getComputedRole(
9+
'div',
10+
[JSXAttributeMock('role', 'button')],
11+
),
12+
'button',
13+
'explicit role + valid role -> returns the role',
14+
);
15+
16+
t.equal(
17+
getComputedRole(
18+
'li',
19+
[JSXAttributeMock('role', 'beeswax')],
20+
),
21+
'listitem',
22+
'explicit role + invalid role + has implicit -> returns the implicit role',
23+
);
24+
25+
t.equal(
26+
getComputedRole(
27+
'div',
28+
[JSXAttributeMock('role', 'beeswax')],
29+
),
30+
null,
31+
'explicit role + invalid role + lacks implicit -> returns null',
32+
);
33+
34+
t.equal(
35+
getComputedRole(
36+
'li',
37+
[],
38+
),
39+
'listitem',
40+
'explicit role + no role + has implicit -> returns the implicit role',
41+
);
42+
43+
t.equal(
44+
getComputedRole(
45+
'div',
46+
[],
47+
),
48+
null,
49+
'explicit role + no role + lacks implicit -> returns null',
50+
);
51+
52+
t.equal(
53+
getComputedRole(
54+
'li',
55+
[JSXAttributeMock('role', 'beeswax')],
56+
),
57+
'listitem',
58+
'implicit role + has implicit -> returns the implicit role',
59+
);
60+
61+
t.equal(
62+
getComputedRole(
63+
'div',
64+
[],
65+
),
66+
null,
67+
'implicit role + lacks implicit -> returns null',
68+
);
3369

34-
describe('no role', () => {
35-
describe('has implicit', () => {
36-
it('should return the implicit role', () => {
37-
expect(getComputedRole(
38-
'li',
39-
[],
40-
)).toBe('listitem');
41-
});
42-
});
43-
describe('lacks implicit', () => {
44-
it('should return null', () => {
45-
expect(getComputedRole(
46-
'div',
47-
[],
48-
)).toBeNull();
49-
});
50-
});
51-
});
52-
});
53-
describe('implicit role', () => {
54-
describe('has implicit', () => {
55-
it('should return the implicit role', () => {
56-
expect(getComputedRole(
57-
'li',
58-
[JSXAttributeMock('role', 'beeswax')],
59-
)).toBe('listitem');
60-
});
61-
});
62-
describe('lacks implicit', () => {
63-
it('should return null', () => {
64-
expect(getComputedRole(
65-
'div',
66-
[],
67-
)).toBeNull();
68-
});
69-
});
70-
});
70+
t.end();
7171
});
+69-38
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import getElementType from '../../../src/util/getElementType';
34
import JSXElementMock from '../../../__mocks__/JSXElementMock';
45
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
56

6-
describe('getElementType', () => {
7-
describe('no settings in context', () => {
7+
test('getElementType', (t) => {
8+
t.test('no settings in context', (st) => {
89
const elementType = getElementType({ settings: {} });
910

10-
it('should return the exact tag name for a DOM element', () => {
11-
expect(elementType(JSXElementMock('input').openingElement)).toBe('input');
12-
});
11+
st.equal(
12+
elementType(JSXElementMock('input').openingElement),
13+
'input',
14+
'returns the exact tag name for a DOM element',
15+
);
1316

14-
it('should return the exact tag name for a custom element', () => {
15-
expect(elementType(JSXElementMock('CustomInput').openingElement)).toBe('CustomInput');
16-
});
17+
st.equal(
18+
elementType(JSXElementMock('CustomInput').openingElement),
19+
'CustomInput',
20+
'returns the exact tag name for a custom element',
21+
);
1722

18-
it('should return the exact tag name for names that are in Object.prototype', () => {
19-
expect(elementType(JSXElementMock('toString').openingElement)).toBe('toString');
20-
});
23+
st.equal(
24+
elementType(JSXElementMock('toString').openingElement),
25+
'toString',
26+
'returns the exact tag name for names that are in Object.prototype',
27+
);
2128

22-
it('should return the default tag name provided', () => {
23-
expect(elementType(JSXElementMock('span', [JSXAttributeMock('as', 'h1')]).openingElement)).toBe('span');
24-
});
29+
st.equal(
30+
elementType(JSXElementMock('span', [JSXAttributeMock('as', 'h1')]).openingElement),
31+
'span',
32+
'returns the default tag name provided',
33+
);
34+
35+
st.end();
2536
});
2637

27-
describe('components settings in context', () => {
38+
t.test('components settings in context', (st) => {
2839
const elementType = getElementType({
2940
settings: {
3041
'jsx-a11y': {
@@ -35,24 +46,34 @@ describe('getElementType', () => {
3546
},
3647
});
3748

38-
it('should return the exact tag name for a DOM element', () => {
39-
expect(elementType(JSXElementMock('input').openingElement)).toBe('input');
40-
});
49+
st.equal(
50+
elementType(JSXElementMock('input').openingElement),
51+
'input',
52+
'returns the exact tag name for a DOM element',
53+
);
4154

42-
it('should return the mapped tag name for a custom element', () => {
43-
expect(elementType(JSXElementMock('CustomInput').openingElement)).toBe('input');
44-
});
55+
st.equal(
56+
elementType(JSXElementMock('CustomInput').openingElement),
57+
'input',
58+
'returns the mapped tag name for a custom element',
59+
);
4560

46-
it('should return the exact tag name for a custom element not in the components map', () => {
47-
expect(elementType(JSXElementMock('CityInput').openingElement)).toBe('CityInput');
48-
});
61+
st.equal(
62+
elementType(JSXElementMock('CityInput').openingElement),
63+
'CityInput',
64+
'returns the exact tag name for a custom element not in the components map',
65+
);
4966

50-
it('should return the default tag name since not polymorphicPropName was provided', () => {
51-
expect(elementType(JSXElementMock('span', [JSXAttributeMock('as', 'h1')]).openingElement)).toBe('span');
52-
});
67+
st.equal(
68+
elementType(JSXElementMock('span', [JSXAttributeMock('as', 'h1')]).openingElement),
69+
'span',
70+
'return the default tag name since not polymorphicPropName was provided',
71+
);
72+
73+
st.end();
5374
});
5475

55-
describe('polymorphicPropName settings in context', () => {
76+
t.test('polymorphicPropName settings in context', (st) => {
5677
const elementType = getElementType({
5778
settings: {
5879
'jsx-a11y': {
@@ -64,16 +85,26 @@ describe('getElementType', () => {
6485
},
6586
});
6687

67-
it('should return the tag name provided by the polymorphic prop, "asChild", defined in the settings', () => {
68-
expect(elementType(JSXElementMock('span', [JSXAttributeMock('asChild', 'h1')]).openingElement)).toBe('h1');
69-
});
88+
st.equal(
89+
elementType(JSXElementMock('span', [JSXAttributeMock('asChild', 'h1')]).openingElement),
90+
'h1',
91+
'returns the tag name provided by the polymorphic prop, "asChild", defined in the settings',
92+
);
7093

71-
it('should return the tag name provided by the polymorphic prop, "asChild", defined in the settings instead of the component mapping tag', () => {
72-
expect(elementType(JSXElementMock('CustomButton', [JSXAttributeMock('asChild', 'a')]).openingElement)).toBe('a');
73-
});
94+
st.equal(
95+
elementType(JSXElementMock('CustomButton', [JSXAttributeMock('asChild', 'a')]).openingElement),
96+
'a',
97+
'returns the tag name provided by the polymorphic prop, "asChild", defined in the settings instead of the component mapping tag',
98+
);
7499

75-
it('should return the tag name provided by the componnet mapping if the polymorphic prop, "asChild", defined in the settings is not set', () => {
76-
expect(elementType(JSXElementMock('CustomButton', [JSXAttributeMock('as', 'a')]).openingElement)).toBe('button');
77-
});
100+
st.equal(
101+
elementType(JSXElementMock('CustomButton', [JSXAttributeMock('as', 'a')]).openingElement),
102+
'button',
103+
'returns the tag name provided by the componnet mapping if the polymorphic prop, "asChild", defined in the settings is not set',
104+
);
105+
106+
st.end();
78107
});
108+
109+
t.end();
79110
});
+31-26
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import getExplicitRole from '../../../src/util/getExplicitRole';
34
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
45

5-
describe('getExplicitRole', () => {
6-
describe('valid role', () => {
7-
it('should return the role', () => {
8-
expect(getExplicitRole(
9-
'div',
10-
[JSXAttributeMock('role', 'button')],
11-
)).toBe('button');
12-
});
13-
});
14-
describe('invalid role', () => {
15-
it('should return null', () => {
16-
expect(getExplicitRole(
17-
'div',
18-
[JSXAttributeMock('role', 'beeswax')],
19-
)).toBeNull();
20-
});
21-
});
22-
describe('no role', () => {
23-
it('should return null', () => {
24-
expect(getExplicitRole(
25-
'div',
26-
[],
27-
)).toBeNull();
28-
});
29-
});
6+
test('getExplicitRole', (t) => {
7+
t.equal(
8+
getExplicitRole(
9+
'div',
10+
[JSXAttributeMock('role', 'button')],
11+
),
12+
'button',
13+
'valid role returns the role',
14+
);
15+
16+
t.equal(
17+
getExplicitRole(
18+
'div',
19+
[JSXAttributeMock('role', 'beeswax')],
20+
),
21+
null,
22+
'invalid role returns null',
23+
);
24+
25+
t.equal(
26+
getExplicitRole(
27+
'div',
28+
[],
29+
),
30+
null,
31+
'no role returns null',
32+
);
33+
34+
t.end();
3035
});
+22-18
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import getImplicitRole from '../../../src/util/getImplicitRole';
34

4-
describe('getImplicitRole', () => {
5-
describe('has implicit', () => {
6-
it('should return the implicit role', () => {
7-
expect(getImplicitRole(
8-
'li',
9-
[],
10-
)).toBe('listitem');
11-
});
12-
});
13-
describe('lacks implicit', () => {
14-
it('should return null', () => {
15-
expect(getImplicitRole(
16-
'div',
17-
[],
18-
)).toBeNull();
19-
});
20-
});
5+
test('getImplicitRole', (t) => {
6+
t.equal(
7+
getImplicitRole(
8+
'li',
9+
[],
10+
),
11+
'listitem',
12+
'has implicit, returns implicit role',
13+
);
14+
15+
t.equal(
16+
getImplicitRole(
17+
'div',
18+
[],
19+
),
20+
null,
21+
'lacks implicit, returns null',
22+
);
23+
24+
t.end();
2125
});
+30-45
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,33 @@
1-
import expect from 'expect';
2-
import getSuggestion from '../../../src/util/getSuggestion';
3-
4-
describe('spell check suggestion API', () => {
5-
it('should return no suggestions given empty word and no dictionary', () => {
6-
const word = '';
7-
const expected = [];
8-
const actual = getSuggestion(word);
9-
10-
expect(expected).toEqual(actual);
11-
});
12-
13-
it('should return no suggestions given real word and no dictionary', () => {
14-
const word = 'foo';
15-
const expected = [];
16-
const actual = getSuggestion(word);
17-
18-
expect(expected).toEqual(actual);
19-
});
1+
import test from 'tape';
202

21-
it('should return correct suggestion given real word and a dictionary', () => {
22-
const word = 'fo';
23-
const dictionary = ['foo', 'bar', 'baz'];
24-
const expected = ['foo'];
25-
const actual = getSuggestion(word, dictionary);
26-
27-
expect(expected).toEqual(actual);
28-
});
29-
30-
it('should return multiple correct suggestions given real word and a dictionary', () => {
31-
const word = 'theer';
32-
const dictionary = ['there', 'their', 'foo', 'bar'];
33-
const expected = ['there', 'their'];
34-
const actual = getSuggestion(word, dictionary);
35-
36-
expect(expected).toEqual(actual);
37-
});
38-
39-
it('should return correct # of suggestions given the limit argument', () => {
40-
const word = 'theer';
41-
const dictionary = ['there', 'their', 'foo', 'bar'];
42-
const limit = 1;
43-
const expected = 1;
44-
const actual = getSuggestion(word, dictionary, limit).length;
3+
import getSuggestion from '../../../src/util/getSuggestion';
454

46-
expect(expected).toEqual(actual);
47-
});
5+
test('spell check suggestion API', (t) => {
6+
t.deepEqual([], getSuggestion('foo'), 'returns no suggestions given empty word and no dictionary');
7+
8+
t.deepEqual(
9+
getSuggestion('foo'),
10+
[],
11+
'returns no suggestions given real word and no dictionary',
12+
);
13+
14+
t.deepEqual(
15+
getSuggestion('fo', ['foo', 'bar', 'baz']),
16+
['foo'],
17+
'returns correct suggestion given real word and a dictionary',
18+
);
19+
20+
t.deepEqual(
21+
getSuggestion('theer', ['there', 'their', 'foo', 'bar']),
22+
['there', 'their'],
23+
'returns multiple correct suggestions given real word and a dictionary',
24+
);
25+
26+
t.deepEqual(
27+
getSuggestion('theer', ['there', 'their', 'foo', 'bar'], 1),
28+
['there'],
29+
'returns correct # of suggestions given the limit argument',
30+
);
31+
32+
t.end();
4833
});
+80-78
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,85 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import getTabIndex from '../../../src/util/getTabIndex';
34
import IdentifierMock from '../../../__mocks__/IdentifierMock';
45
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
56

6-
describe('getTabIndex', () => {
7-
describe('tabIndex is defined', () => {
8-
describe('as a number ', () => {
9-
describe('zero', () => {
10-
it('should return zero', () => {
11-
expect(getTabIndex(JSXAttributeMock('tabIndex', 0))).toBe(0);
12-
});
13-
});
14-
describe('positive integer', () => {
15-
it('should return the integer', () => {
16-
expect(getTabIndex(JSXAttributeMock('tabIndex', 1))).toBe(1);
17-
});
18-
});
19-
describe('negative integer', () => {
20-
it('should return the integer', () => {
21-
expect(getTabIndex(JSXAttributeMock('tabIndex', -1))).toBe(-1);
22-
});
23-
});
24-
describe('float', () => {
25-
it('should return undefined', () => {
26-
expect(getTabIndex(JSXAttributeMock('tabIndex', 9.1))).toBeUndefined();
27-
});
28-
});
29-
});
30-
describe('as a string', () => {
31-
describe('empty', () => {
32-
it('should return undefined', () => {
33-
expect(getTabIndex(JSXAttributeMock('tabIndex', ''))).toBeUndefined();
34-
});
35-
});
36-
describe('which converts to a number', () => {
37-
it('should return an integer', () => {
38-
expect(getTabIndex(JSXAttributeMock('tabIndex', '0'))).toBe(0);
39-
});
40-
});
41-
describe('which is NaN', () => {
42-
it('should return undefined', () => {
43-
expect(getTabIndex(JSXAttributeMock('tabIndex', '0a'))).toBeUndefined();
44-
});
45-
});
46-
});
47-
describe('as a boolean', () => {
48-
describe('true', () => {
49-
it('should return undefined', () => {
50-
expect(getTabIndex(JSXAttributeMock('tabIndex', true))).toBeUndefined();
51-
});
52-
});
53-
describe('false', () => {
54-
it('should return undefined', () => {
55-
expect(getTabIndex(JSXAttributeMock('tabIndex', false))).toBeUndefined();
56-
});
57-
});
58-
});
59-
describe('as an expression', () => {
60-
describe('function expression', () => {
61-
it('should return the correct type', () => {
62-
const attr = function mockFn() { return 0; };
63-
expect(typeof getTabIndex(JSXAttributeMock('tabIndex', attr))).toEqual('function');
64-
});
65-
});
66-
describe('variable expression', () => {
67-
it('should return the Identifier name', () => {
68-
const name = 'identName';
69-
expect(getTabIndex(JSXAttributeMock(
70-
'tabIndex',
71-
IdentifierMock(name),
72-
true,
73-
))).toEqual(name);
74-
});
75-
});
76-
});
77-
});
78-
describe('tabIndex is not defined', () => {
79-
it('should return undefined', () => {
80-
expect(getTabIndex(JSXAttributeMock('tabIndex', undefined))).toBeUndefined();
81-
});
82-
});
7+
test('getTabIndex', (t) => {
8+
t.equal(
9+
getTabIndex(JSXAttributeMock('tabIndex', 0)),
10+
0,
11+
'tabIndex is defined as zero -> zero',
12+
);
13+
14+
t.equal(
15+
getTabIndex(JSXAttributeMock('tabIndex', 1)),
16+
1,
17+
'tabIndex is defined as a positive integer -> returns it',
18+
);
19+
20+
t.equal(
21+
getTabIndex(JSXAttributeMock('tabIndex', -1)),
22+
-1,
23+
'tabIndex is defined as a negative integer -> returns it',
24+
);
25+
26+
t.equal(
27+
getTabIndex(JSXAttributeMock('tabIndex', '')),
28+
undefined,
29+
'tabIndex is defined as an empty string -> undefined',
30+
);
31+
32+
t.equal(
33+
getTabIndex(JSXAttributeMock('tabIndex', 9.1)),
34+
undefined,
35+
'tabIndex is defined as a float -> undefined',
36+
);
37+
38+
t.equal(
39+
getTabIndex(JSXAttributeMock('tabIndex', '0')),
40+
0,
41+
'tabIndex is defined as a string which converts to a number -> returns the integer',
42+
);
43+
44+
t.equal(
45+
getTabIndex(JSXAttributeMock('tabIndex', '0a')),
46+
undefined,
47+
'tabIndex is defined as a string which is NaN -> returns undefined',
48+
);
49+
50+
t.equal(
51+
getTabIndex(JSXAttributeMock('tabIndex', true)),
52+
undefined,
53+
'tabIndex is defined as true -> returns undefined',
54+
);
55+
t.equal(
56+
getTabIndex(JSXAttributeMock('tabIndex', false)),
57+
undefined,
58+
'tabIndex is defined as false -> returns undefined',
59+
);
60+
61+
t.equal(
62+
typeof getTabIndex(JSXAttributeMock('tabIndex', () => 0)),
63+
'function',
64+
'tabIndex is defined as a function expression -> returns the correct type',
65+
);
66+
67+
const name = 'identName';
68+
t.equal(
69+
getTabIndex(JSXAttributeMock(
70+
'tabIndex',
71+
IdentifierMock(name),
72+
true,
73+
)),
74+
name,
75+
'tabIndex is defined as a variable expression -> returns the Identifier name',
76+
);
77+
78+
t.equal(
79+
getTabIndex(JSXAttributeMock('tabIndex', undefined)),
80+
undefined,
81+
'tabIndex is not defined -> returns undefined',
82+
);
83+
84+
t.end();
8385
});
+135-85
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,157 @@
1-
import expect from 'expect';
1+
import test from 'tape';
22
import { elementType } from 'jsx-ast-utils';
3+
34
import hasAccessibleChild from '../../../src/util/hasAccessibleChild';
45
import JSXElementMock from '../../../__mocks__/JSXElementMock';
56
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
67
import JSXExpressionContainerMock from '../../../__mocks__/JSXExpressionContainerMock';
78

8-
describe('hasAccessibleChild', () => {
9-
describe('has no children and does not set dangerouslySetInnerHTML', () => {
10-
it('returns false', () => {
11-
expect(hasAccessibleChild(JSXElementMock('div', []), elementType)).toBe(false);
12-
});
13-
});
9+
test('hasAccessibleChild', (t) => {
10+
t.equal(
11+
hasAccessibleChild(JSXElementMock('div', []), elementType),
12+
false,
13+
'has no children and does not set dangerouslySetInnerHTML -> false',
14+
);
1415

15-
describe('has no children and sets dangerouslySetInnerHTML', () => {
16-
it('Returns true', () => {
17-
const prop = JSXAttributeMock('dangerouslySetInnerHTML', true);
18-
const element = JSXElementMock('div', [prop], []);
19-
expect(hasAccessibleChild(element, elementType)).toBe(true);
20-
});
21-
});
16+
t.equal(
17+
hasAccessibleChild(
18+
JSXElementMock('div', [JSXAttributeMock('dangerouslySetInnerHTML', true)], []),
19+
elementType,
20+
),
21+
true,
22+
'has no children and sets dangerouslySetInnerHTML -> true',
23+
);
2224

23-
describe('has children', () => {
24-
it('Returns true for a Literal child', () => {
25-
const child = {
26-
type: 'Literal',
27-
value: 'foo',
28-
};
29-
const element = JSXElementMock('div', [], [child]);
30-
expect(hasAccessibleChild(element, elementType)).toBe(true);
31-
});
25+
t.equal(
26+
hasAccessibleChild(
27+
JSXElementMock(
28+
'div',
29+
[],
30+
[{
31+
type: 'Literal',
32+
value: 'foo',
33+
}],
34+
),
35+
elementType,
36+
),
37+
true,
38+
'has children + Literal child -> true',
39+
);
3240

33-
it('Returns true for visible child JSXElement', () => {
34-
const child = JSXElementMock('div', []);
35-
const element = JSXElementMock('div', [], [child]);
36-
expect(hasAccessibleChild(element, elementType)).toBe(true);
37-
});
41+
t.equal(
42+
hasAccessibleChild(
43+
JSXElementMock('div', [], [JSXElementMock('div', [])]),
44+
elementType,
45+
),
46+
true,
47+
'has children + visible JSXElement child -> true',
48+
);
3849

39-
it('Returns true for JSXText Element', () => {
40-
const child = {
50+
t.equal(
51+
hasAccessibleChild(
52+
JSXElementMock('div', [], [{
4153
type: 'JSXText',
4254
value: 'foo',
43-
};
44-
const element = JSXElementMock('div', [], [child]);
45-
expect(hasAccessibleChild(element, elementType)).toBe(true);
46-
});
55+
}]),
56+
elementType,
57+
),
58+
true,
59+
'has children + JSText element -> true',
60+
);
4761

48-
it('Returns false for hidden child JSXElement', () => {
49-
const ariaHiddenAttr = JSXAttributeMock('aria-hidden', true);
50-
const child = JSXElementMock('div', [ariaHiddenAttr]);
51-
const element = JSXElementMock('div', [], [child]);
52-
expect(hasAccessibleChild(element, elementType)).toBe(false);
53-
});
62+
t.equal(
63+
hasAccessibleChild(
64+
JSXElementMock('div', [], [
65+
JSXElementMock('div', [
66+
JSXAttributeMock('aria-hidden', true),
67+
]),
68+
]),
69+
elementType,
70+
),
71+
false,
72+
'has children + hidden child JSXElement -> false',
73+
);
5474

55-
it('Returns true for defined JSXExpressionContainer', () => {
56-
const expression = {
57-
type: 'Identifier',
58-
name: 'foo',
59-
};
60-
const child = JSXExpressionContainerMock(expression);
61-
const element = JSXElementMock('div', [], [child]);
62-
expect(hasAccessibleChild(element, elementType)).toBe(true);
63-
});
75+
t.equal(
76+
hasAccessibleChild(
77+
JSXElementMock('div', [], [
78+
JSXExpressionContainerMock({
79+
type: 'Identifier',
80+
name: 'foo',
81+
}),
82+
]),
83+
elementType,
84+
),
85+
true,
86+
'defined JSXExpressionContainer -> true',
87+
);
6488

65-
it('Returns false for undefined JSXExpressionContainer', () => {
66-
const expression = {
67-
type: 'Identifier',
68-
name: 'undefined',
69-
};
70-
const child = JSXExpressionContainerMock(expression);
71-
const element = JSXElementMock('div', [], [child]);
72-
expect(hasAccessibleChild(element, elementType)).toBe(false);
73-
});
89+
t.equal(
90+
hasAccessibleChild(
91+
JSXElementMock('div', [], [
92+
JSXExpressionContainerMock({
93+
type: 'Identifier',
94+
name: 'undefined',
95+
}),
96+
]),
97+
elementType,
98+
),
99+
false,
100+
'has children + undefined JSXExpressionContainer -> false',
101+
);
74102

75-
it('Returns false for unknown child type', () => {
76-
const child = {
103+
t.equal(
104+
hasAccessibleChild(
105+
JSXElementMock('div', [], [{
77106
type: 'Unknown',
78-
};
79-
const element = JSXElementMock('div', [], [child]);
80-
expect(hasAccessibleChild(element, elementType)).toBe(false);
81-
});
107+
}]),
108+
elementType,
109+
),
110+
false,
111+
'unknown child type -> false',
112+
);
113+
114+
t.equal(
115+
hasAccessibleChild(
116+
JSXElementMock('div', [JSXAttributeMock('children', true)], []),
117+
elementType,
118+
),
119+
true,
120+
'children passed as a prop -> true',
121+
);
82122

83-
it('Returns true with children passed as a prop', () => {
84-
const children = JSXAttributeMock('children', true);
85-
const element = JSXElementMock('div', [children], []);
86-
expect(hasAccessibleChild(element, elementType)).toBe(true);
87-
});
123+
t.equal(
124+
hasAccessibleChild(
125+
JSXElementMock('div', [], [
126+
JSXElementMock('input', [JSXAttributeMock('type', 'hidden')]),
127+
]),
128+
elementType,
129+
),
130+
false,
131+
'has chidren -> hidden child input JSXElement -> false',
132+
);
88133

89-
it('Returns false for hidden child input JSXElement', () => {
90-
const child = JSXElementMock('input', [JSXAttributeMock('type', 'hidden')]);
91-
const element = JSXElementMock('div', [], [child]);
92-
expect(hasAccessibleChild(element, elementType)).toBe(false);
93-
});
134+
t.equal(
135+
hasAccessibleChild(
136+
JSXElementMock('div', [], [
137+
JSXElementMock('CustomInput', [JSXAttributeMock('type', 'hidden')]),
138+
]),
139+
elementType,
140+
),
141+
true,
142+
'has children + custom JSXElement of type hidden -> true',
143+
);
94144

95-
it('Returns true for a custom JSXElement even if type hidden', () => {
96-
const child = JSXElementMock('CustomInput', [JSXAttributeMock('type', 'hidden')]);
97-
const element = JSXElementMock('div', [], [child]);
98-
expect(hasAccessibleChild(element, elementType)).toBe(true);
99-
});
145+
t.equal(
146+
hasAccessibleChild(
147+
JSXElementMock('div', [], [
148+
JSXElementMock('CustomInput', [JSXAttributeMock('type', 'hidden')]),
149+
]),
150+
() => 'input',
151+
),
152+
false,
153+
'custom JSXElement mapped to input if type is hidden -> false',
154+
);
100155

101-
it('Returns false for a custom JSXElement mapped to input if type is hidden', () => {
102-
const child = JSXElementMock('CustomInput', [JSXAttributeMock('type', 'hidden')]);
103-
const element = JSXElementMock('div', [], [child]);
104-
expect(hasAccessibleChild(element, () => 'input')).toBe(false);
105-
});
106-
});
156+
t.end();
107157
});
+81-28
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,87 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import JSXAttributeMock from '../../../../__mocks__/JSXAttributeMock';
34
import getImplicitRoleForInput from '../../../../src/util/implicitRoles/input';
45

5-
describe('isAbstractRole', () => {
6-
it('works for buttons', () => {
7-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'button')])).toBe('button');
8-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'image')])).toBe('button');
9-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'reset')])).toBe('button');
10-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'submit')])).toBe('button');
11-
});
12-
it('works for checkboxes', () => {
13-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'checkbox')])).toBe('checkbox');
14-
});
15-
it('works for radios', () => {
16-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'radio')])).toBe('radio');
17-
});
18-
it('works for ranges', () => {
19-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'range')])).toBe('slider');
20-
});
21-
it('works for textboxes', () => {
22-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'email')])).toBe('textbox');
23-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'password')])).toBe('textbox');
24-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'search')])).toBe('textbox');
25-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'tel')])).toBe('textbox');
26-
expect(getImplicitRoleForInput([JSXAttributeMock('type', 'url')])).toBe('textbox');
27-
});
28-
it('works for the default case', () => {
29-
expect(getImplicitRoleForInput([JSXAttributeMock('type', '')])).toBe('textbox');
6+
test('isAbstractRole', (t) => {
7+
t.test('works for buttons', (st) => {
8+
st.equal(
9+
getImplicitRoleForInput([JSXAttributeMock('type', 'button')]),
10+
'button',
11+
);
12+
13+
st.equal(
14+
getImplicitRoleForInput([JSXAttributeMock('type', 'image')]),
15+
'button',
16+
);
17+
18+
st.equal(
19+
getImplicitRoleForInput([JSXAttributeMock('type', 'reset')]),
20+
'button',
21+
);
22+
23+
st.equal(
24+
getImplicitRoleForInput([JSXAttributeMock('type', 'submit')]),
25+
'button',
26+
);
27+
28+
st.end();
3029
});
31-
it('works for the true case', () => {
32-
expect(getImplicitRoleForInput([JSXAttributeMock('type', true)])).toBe('textbox');
30+
31+
t.equal(
32+
getImplicitRoleForInput([JSXAttributeMock('type', 'checkbox')]),
33+
'checkbox',
34+
'works for checkboxes',
35+
);
36+
37+
t.equal(
38+
getImplicitRoleForInput([JSXAttributeMock('type', 'radio')]),
39+
'radio',
40+
'works for radios',
41+
);
42+
43+
t.equal(
44+
getImplicitRoleForInput([JSXAttributeMock('type', 'range')]),
45+
'slider',
46+
'works for ranges',
47+
);
48+
49+
t.test('works for textboxes', (st) => {
50+
st.equal(
51+
getImplicitRoleForInput([JSXAttributeMock('type', 'email')]),
52+
'textbox',
53+
);
54+
st.equal(
55+
getImplicitRoleForInput([JSXAttributeMock('type', 'password')]),
56+
'textbox',
57+
);
58+
st.equal(
59+
getImplicitRoleForInput([JSXAttributeMock('type', 'search')]),
60+
'textbox',
61+
);
62+
st.equal(
63+
getImplicitRoleForInput([JSXAttributeMock('type', 'tel')]),
64+
'textbox',
65+
);
66+
st.equal(
67+
getImplicitRoleForInput([JSXAttributeMock('type', 'url')]),
68+
'textbox',
69+
);
70+
71+
st.end();
3372
});
73+
74+
t.equal(
75+
getImplicitRoleForInput([JSXAttributeMock('type', '')]),
76+
'textbox',
77+
'works for the default case',
78+
);
79+
80+
t.equal(
81+
getImplicitRoleForInput([JSXAttributeMock('type', true)]),
82+
'textbox',
83+
'works for the true case',
84+
);
85+
86+
t.end();
3487
});
+16-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import JSXAttributeMock from '../../../../__mocks__/JSXAttributeMock';
34
import getImplicitRoleForMenu from '../../../../src/util/implicitRoles/menu';
45

5-
describe('isAbstractRole', () => {
6-
it('works for toolbars', () => {
7-
expect(getImplicitRoleForMenu([JSXAttributeMock('type', 'toolbar')])).toBe('toolbar');
8-
});
9-
it('works for non-toolbars', () => {
10-
expect(getImplicitRoleForMenu([JSXAttributeMock('type', '')])).toBe('');
11-
});
6+
test('isAbstractRole', (t) => {
7+
t.equal(
8+
getImplicitRoleForMenu([JSXAttributeMock('type', 'toolbar')]),
9+
'toolbar',
10+
'works for toolbars',
11+
);
12+
13+
t.equal(
14+
getImplicitRoleForMenu([JSXAttributeMock('type', '')]),
15+
'',
16+
'works for non-toolbars',
17+
);
18+
19+
t.end();
1220
});
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import JSXAttributeMock from '../../../../__mocks__/JSXAttributeMock';
34
import getImplicitRoleForMenuitem from '../../../../src/util/implicitRoles/menuitem';
45

5-
describe('isAbstractRole', () => {
6-
it('works for menu items', () => {
7-
expect(getImplicitRoleForMenuitem([JSXAttributeMock('type', 'command')])).toBe('menuitem');
8-
});
9-
it('works for menu item checkboxes', () => {
10-
expect(getImplicitRoleForMenuitem([JSXAttributeMock('type', 'checkbox')])).toBe('menuitemcheckbox');
11-
});
12-
it('works for menu item radios', () => {
13-
expect(getImplicitRoleForMenuitem([JSXAttributeMock('type', 'radio')])).toBe('menuitemradio');
14-
});
15-
it('works for non-toolbars', () => {
16-
expect(getImplicitRoleForMenuitem([JSXAttributeMock('type', '')])).toBe('');
17-
});
18-
it('works for the true case', () => {
19-
expect(getImplicitRoleForMenuitem([JSXAttributeMock('type', true)])).toBe('');
20-
});
6+
test('isAbstractRole', (t) => {
7+
t.equal(
8+
getImplicitRoleForMenuitem([JSXAttributeMock('type', 'command')]),
9+
'menuitem',
10+
'works for menu items',
11+
);
12+
13+
t.equal(
14+
getImplicitRoleForMenuitem([JSXAttributeMock('type', 'checkbox')]),
15+
'menuitemcheckbox',
16+
'works for menu item checkboxes',
17+
);
18+
19+
t.equal(
20+
getImplicitRoleForMenuitem([JSXAttributeMock('type', 'radio')]),
21+
'menuitemradio',
22+
'works for menu item radios',
23+
);
24+
25+
t.equal(
26+
getImplicitRoleForMenuitem([JSXAttributeMock('type', '')]),
27+
'',
28+
'works for non-toolbars',
29+
);
30+
31+
t.equal(
32+
getImplicitRoleForMenuitem([JSXAttributeMock('type', true)]),
33+
'',
34+
'works for the true case',
35+
);
36+
37+
t.end();
2138
});
+30-18
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,51 @@
1-
import expect from 'expect';
1+
import test from 'tape';
22
import { elementType } from 'jsx-ast-utils';
3+
34
import isAbstractRole from '../../../src/util/isAbstractRole';
45
import {
56
genElementSymbol,
67
genAbstractRoleElements,
78
genNonAbstractRoleElements,
89
} from '../../../__mocks__/genInteractives';
910

10-
describe('isAbstractRole', () => {
11-
describe('JSX Components (no tagName)', () => {
12-
it('should NOT identify them as abstract role elements', () => {
13-
expect(isAbstractRole(undefined, []))
14-
.toBe(false);
15-
});
16-
});
17-
describe('elements with an abstract role', () => {
11+
test('isAbstractRole', (t) => {
12+
t.equal(
13+
isAbstractRole(undefined, []),
14+
false,
15+
'does NOT identify JSX Components (no tagName) as abstract role elements',
16+
);
17+
18+
t.test('elements with an abstract role', (st) => {
1819
genAbstractRoleElements().forEach(({ openingElement }) => {
1920
const { attributes } = openingElement;
20-
it(`should identify \`${genElementSymbol(openingElement)}\` as an abstract role element`, () => {
21-
expect(isAbstractRole(
21+
st.equal(
22+
isAbstractRole(
2223
elementType(openingElement),
2324
attributes,
24-
)).toBe(true);
25-
});
25+
),
26+
true,
27+
`identifies \`${genElementSymbol(openingElement)}\` as an abstract role element`,
28+
);
2629
});
30+
31+
st.end();
2732
});
28-
describe('elements with a non-abstract role', () => {
33+
34+
t.test('elements with a non-abstract role', (st) => {
2935
genNonAbstractRoleElements().forEach(({ openingElement }) => {
3036
const { attributes } = openingElement;
31-
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as an abstract role element`, () => {
32-
expect(isAbstractRole(
37+
st.equal(
38+
isAbstractRole(
3339
elementType(openingElement),
3440
attributes,
35-
)).toBe(false);
36-
});
41+
),
42+
false,
43+
`does NOT identify \`${genElementSymbol(openingElement)}\` as an abstract role element`,
44+
);
3745
});
46+
47+
st.end();
3848
});
49+
50+
t.end();
3951
});
+47-46
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,52 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import isContentEditable from '../../../src/util/isContentEditable';
34
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
45

5-
describe('isContentEditable', () => {
6-
describe('HTML5', () => {
7-
describe('content editable', () => {
8-
it('should identify HTML5 contentEditable elements', () => {
9-
const attributes = [
10-
JSXAttributeMock('contentEditable', 'true'),
11-
];
12-
expect(isContentEditable('some tag', attributes))
13-
.toBe(true);
14-
});
15-
});
16-
17-
describe('not content editable', () => {
18-
it('should not identify HTML5 content editable elements with null as the value', () => {
19-
const attributes = [
20-
JSXAttributeMock('contentEditable', null),
21-
];
22-
expect(isContentEditable('some tag', attributes))
23-
.toBe(false);
24-
});
25-
26-
it('should not identify HTML5 content editable elements with undefined as the value', () => {
27-
const attributes = [
28-
JSXAttributeMock('contentEditable', undefined),
29-
];
30-
expect(isContentEditable('some tag', attributes))
31-
.toBe(false);
32-
});
33-
34-
it('should not identify HTML5 content editable elements with true as the value', () => {
35-
const attributes = [
36-
JSXAttributeMock('contentEditable', true),
37-
];
38-
expect(isContentEditable('some tag', attributes))
39-
.toBe(false);
40-
});
41-
42-
it('should not identify HTML5 content editable elements with "false" as the value', () => {
43-
const attributes = [
44-
JSXAttributeMock('contentEditable', 'false'),
45-
];
46-
expect(isContentEditable('some tag', attributes))
47-
.toBe(false);
48-
});
49-
});
6+
test('isContentEditable - HTML5', (t) => {
7+
t.equal(
8+
isContentEditable('some tag', [
9+
JSXAttributeMock('contentEditable', 'true'),
10+
]),
11+
true,
12+
'identifies HTML5 contentEditable elements',
13+
);
14+
15+
t.test('not content editable', (st) => {
16+
st.equal(
17+
isContentEditable('some tag', [
18+
JSXAttributeMock('contentEditable', null),
19+
]),
20+
false,
21+
'does not identify HTML5 content editable elements with null as the value',
22+
);
23+
24+
st.equal(
25+
isContentEditable('some tag', [
26+
JSXAttributeMock('contentEditable', undefined),
27+
]),
28+
false,
29+
'does not identify HTML5 content editable elements with undefined as the value',
30+
);
31+
32+
st.equal(
33+
isContentEditable('some tag', [
34+
JSXAttributeMock('contentEditable', true),
35+
]),
36+
false,
37+
'does not identify HTML5 content editable elements with true as the value',
38+
);
39+
40+
st.equal(
41+
isContentEditable('some tag', [
42+
JSXAttributeMock('contentEditable', 'false'),
43+
]),
44+
false,
45+
'does not identify HTML5 content editable elements with "false" as the value',
46+
);
47+
48+
st.end();
5049
});
50+
51+
t.end();
5152
});
+21-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
1-
import expect from 'expect';
1+
import test from 'tape';
22
import { dom } from 'aria-query';
33
import { elementType } from 'jsx-ast-utils';
4+
45
import isDOMElement from '../../../src/util/isDOMElement';
56
import JSXElementMock from '../../../__mocks__/JSXElementMock';
67

7-
describe('isDOMElement', () => {
8-
describe('DOM elements', () => {
8+
test('isDOMElement', (t) => {
9+
t.test('DOM elements', (st) => {
910
dom.forEach((_, el) => {
10-
it(`should identify ${el} as a DOM element`, () => {
11-
const element = JSXElementMock(el);
12-
expect(isDOMElement(elementType(element.openingElement)))
13-
.toBe(true);
14-
});
15-
});
16-
});
17-
describe('Custom Element', () => {
18-
it('should not identify a custom element', () => {
19-
const element = JSXElementMock('CustomElement');
20-
expect(isDOMElement(element))
21-
.toBe(false);
11+
const element = JSXElementMock(el);
12+
13+
st.equal(
14+
isDOMElement(elementType(element.openingElement)),
15+
true,
16+
`identifies ${el} as a DOM element`,
17+
);
2218
});
19+
20+
st.end();
2321
});
22+
23+
t.equal(
24+
isDOMElement(JSXElementMock('CustomElement')),
25+
false,
26+
'does not identify a custom element',
27+
);
28+
29+
t.end();
2430
});
+82-75
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,88 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import isDisabledElement from '../../../src/util/isDisabledElement';
34
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
45

5-
describe('isDisabledElement', () => {
6-
describe('HTML5', () => {
7-
describe('disabled', () => {
8-
it('should identify HTML5 disabled elements', () => {
9-
const attributes = [
10-
JSXAttributeMock('disabled', 'disabled'),
11-
];
12-
expect(isDisabledElement(attributes))
13-
.toBe(true);
14-
});
15-
});
16-
describe('not disabled', () => {
17-
it('should identify HTML5 disabled elements with null as the value', () => {
18-
const attributes = [
19-
JSXAttributeMock('disabled', null),
20-
];
21-
expect(isDisabledElement(attributes))
22-
.toBe(true);
23-
});
24-
it('should not identify HTML5 disabled elements with undefined as the value', () => {
25-
const attributes = [
26-
JSXAttributeMock('disabled', undefined),
27-
];
28-
expect(isDisabledElement(attributes))
29-
.toBe(false);
30-
});
31-
});
6+
test('isDisabledElement', (t) => {
7+
t.test('HTML5', (st) => {
8+
st.equal(
9+
isDisabledElement([
10+
JSXAttributeMock('disabled', 'disabled'),
11+
]),
12+
true,
13+
'identifies HTML5 disabled elements',
14+
);
15+
16+
st.equal(
17+
isDisabledElement([
18+
JSXAttributeMock('disabled', null),
19+
]),
20+
true,
21+
'identifies HTML5 disabled elements with null as the value',
22+
);
23+
24+
st.equal(
25+
isDisabledElement([
26+
JSXAttributeMock('disabled', undefined),
27+
]),
28+
false,
29+
'does not identify HTML5 disabled elements with undefined as the value',
30+
);
31+
32+
st.end();
3233
});
33-
describe('ARIA', () => {
34-
describe('disabled', () => {
35-
it('should not identify ARIA disabled elements', () => {
36-
const attributes = [
37-
JSXAttributeMock('aria-disabled', 'true'),
38-
];
39-
expect(isDisabledElement(attributes))
40-
.toBe(true);
41-
});
42-
it('should not identify ARIA disabled elements', () => {
43-
const attributes = [
44-
JSXAttributeMock('aria-disabled', true),
45-
];
46-
expect(isDisabledElement(attributes))
47-
.toBe(true);
48-
});
49-
});
50-
describe('not disabled', () => {
51-
it('should not identify ARIA disabled elements', () => {
52-
const attributes = [
53-
JSXAttributeMock('aria-disabled', 'false'),
54-
];
55-
expect(isDisabledElement(attributes))
56-
.toBe(false);
57-
});
58-
it('should not identify ARIA disabled elements', () => {
59-
const attributes = [
60-
JSXAttributeMock('aria-disabled', false),
61-
];
62-
expect(isDisabledElement(attributes))
63-
.toBe(false);
64-
});
65-
it('should not identify ARIA disabled elements with null as the value', () => {
66-
const attributes = [
67-
JSXAttributeMock('aria-disabled', null),
68-
];
69-
expect(isDisabledElement(attributes))
70-
.toBe(false);
71-
});
72-
it('should not identify ARIA disabled elements with undefined as the value', () => {
73-
const attributes = [
74-
JSXAttributeMock('aria-disabled', undefined),
75-
];
76-
expect(isDisabledElement(attributes))
77-
.toBe(false);
78-
});
79-
});
34+
35+
t.test('ARIA', (st) => {
36+
st.equal(
37+
isDisabledElement([
38+
JSXAttributeMock('aria-disabled', 'true'),
39+
]),
40+
true,
41+
'does not identify ARIA disabled elements',
42+
);
43+
44+
st.equal(
45+
isDisabledElement([
46+
JSXAttributeMock('aria-disabled', true),
47+
]),
48+
true,
49+
'does not identify ARIA disabled elements',
50+
);
51+
52+
st.equal(
53+
isDisabledElement([
54+
JSXAttributeMock('aria-disabled', 'false'),
55+
]),
56+
false,
57+
'does not identify ARIA disabled elements',
58+
);
59+
60+
st.equal(
61+
isDisabledElement([
62+
JSXAttributeMock('aria-disabled', false),
63+
]),
64+
false,
65+
'does not identify ARIA disabled elements',
66+
);
67+
68+
st.equal(
69+
isDisabledElement([
70+
JSXAttributeMock('aria-disabled', null),
71+
]),
72+
false,
73+
'does not identify ARIA disabled elements with null as the value',
74+
);
75+
76+
st.equal(
77+
isDisabledElement([
78+
JSXAttributeMock('aria-disabled', undefined),
79+
]),
80+
false,
81+
'does not identify ARIA disabled elements with undefined as the value',
82+
);
83+
84+
st.end();
8085
});
86+
87+
t.end();
8188
});
+65-40
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import expect from 'expect';
1+
import test from 'tape';
22
import { elementType } from 'jsx-ast-utils';
3+
34
import isFocusable from '../../../src/util/isFocusable';
45
import {
56
genElementSymbol,
@@ -12,75 +13,99 @@ function mergeTabIndex(index, attributes) {
1213
return [].concat(attributes, JSXAttributeMock('tabIndex', index));
1314
}
1415

15-
describe('isFocusable', () => {
16-
describe('interactive elements', () => {
16+
test('isFocusable', (t) => {
17+
t.test('interactive elements', (st) => {
1718
genInteractiveElements().forEach(({ openingElement }) => {
18-
it(`should identify \`${genElementSymbol(openingElement)}\` as a focusable element`, () => {
19-
expect(isFocusable(
19+
st.equal(
20+
isFocusable(
2021
elementType(openingElement),
2122
openingElement.attributes,
22-
)).toBe(true);
23-
});
23+
),
24+
true,
25+
`identifies \`${genElementSymbol(openingElement)}\` as a focusable element`,
26+
);
2427

25-
it(`should not identify \`${genElementSymbol(openingElement)}\` with tabIndex of -1 as a focusable element`, () => {
26-
expect(isFocusable(
28+
st.equal(
29+
isFocusable(
2730
elementType(openingElement),
2831
mergeTabIndex(-1, openingElement.attributes),
29-
)).toBe(false);
30-
});
32+
),
33+
false,
34+
`does NOT identify \`${genElementSymbol(openingElement)}\` with tabIndex of -1 as a focusable element`,
35+
);
3136

32-
it(`should identify \`${genElementSymbol(openingElement)}\` with tabIndex of 0 as a focusable element`, () => {
33-
expect(isFocusable(
37+
st.equal(
38+
isFocusable(
3439
elementType(openingElement),
3540
mergeTabIndex(0, openingElement.attributes),
36-
)).toBe(true);
37-
});
41+
),
42+
true,
43+
`identifies \`${genElementSymbol(openingElement)}\` with tabIndex of 0 as a focusable element`,
44+
);
3845

39-
it(`should identify \`${genElementSymbol(openingElement)}\` with tabIndex of 1 as a focusable element`, () => {
40-
expect(isFocusable(
46+
st.equal(
47+
isFocusable(
4148
elementType(openingElement),
4249
mergeTabIndex(1, openingElement.attributes),
43-
)).toBe(true);
44-
});
50+
),
51+
true,
52+
`identifies \`${genElementSymbol(openingElement)}\` with tabIndex of 1 as a focusable element`,
53+
);
4554
});
55+
56+
st.end();
4657
});
4758

48-
describe('non-interactive elements', () => {
59+
t.test('non-interactive elements', (st) => {
4960
genNonInteractiveElements().forEach(({ openingElement }) => {
50-
it(`should not identify \`${genElementSymbol(openingElement)}\` as a focusable element`, () => {
51-
expect(isFocusable(
61+
st.equal(
62+
isFocusable(
5263
elementType(openingElement),
5364
openingElement.attributes,
54-
)).toBe(false);
55-
});
65+
),
66+
false,
67+
`does NOT identify \`${genElementSymbol(openingElement)}\` as a focusable element`,
68+
);
5669

57-
it(`should not identify \`${genElementSymbol(openingElement)}\` with tabIndex of -1 as a focusable element`, () => {
58-
expect(isFocusable(
70+
st.equal(
71+
isFocusable(
5972
elementType(openingElement),
6073
mergeTabIndex(-1, openingElement.attributes),
61-
)).toBe(false);
62-
});
74+
),
75+
false,
76+
`does NOT identify \`${genElementSymbol(openingElement)}\` with tabIndex of -1 as a focusable element`,
77+
);
6378

64-
it(`should identify \`${genElementSymbol(openingElement)}\` with tabIndex of 0 as a focusable element`, () => {
65-
expect(isFocusable(
79+
st.equal(
80+
isFocusable(
6681
elementType(openingElement),
6782
mergeTabIndex(0, openingElement.attributes),
68-
)).toBe(true);
69-
});
83+
),
84+
true,
85+
`identifies \`${genElementSymbol(openingElement)}\` with tabIndex of 0 as a focusable element`,
86+
);
7087

71-
it(`should identify \`${genElementSymbol(openingElement)}\` with tabIndex of 1 as a focusable element`, () => {
72-
expect(isFocusable(
88+
st.equal(
89+
isFocusable(
7390
elementType(openingElement),
7491
mergeTabIndex(1, openingElement.attributes),
75-
)).toBe(true);
76-
});
92+
),
93+
true,
94+
`identifies \`${genElementSymbol(openingElement)}\` with tabIndex of 1 as a focusable element`,
95+
);
7796

78-
it(`should not identify \`${genElementSymbol(openingElement)}\` with tabIndex of 'bogus' as a focusable element`, () => {
79-
expect(isFocusable(
97+
st.equal(
98+
isFocusable(
8099
elementType(openingElement),
81100
mergeTabIndex('bogus', openingElement.attributes),
82-
)).toBe(false);
83-
});
101+
),
102+
false,
103+
`does NOT identify \`${genElementSymbol(openingElement)}\` with tabIndex of 'bogus' as a focusable element`,
104+
);
84105
});
106+
107+
st.end();
85108
});
109+
110+
t.end();
86111
});
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import expect from 'expect';
1+
import test from 'tape';
22
import { elementType } from 'jsx-ast-utils';
3+
34
import isInteractiveElement from '../../../src/util/isInteractiveElement';
45
import JSXElementMock from '../../../__mocks__/JSXElementMock';
56
import {
@@ -11,66 +12,93 @@ import {
1112
genNonInteractiveRoleElements,
1213
} from '../../../__mocks__/genInteractives';
1314

14-
describe('isInteractiveElement', () => {
15-
describe('JSX Components (no tagName)', () => {
16-
it('should identify them as interactive elements', () => {
17-
expect(isInteractiveElement(undefined, []))
18-
.toBe(false);
19-
});
20-
});
21-
describe('interactive elements', () => {
15+
test('isInteractiveElement', (t) => {
16+
t.equal(
17+
isInteractiveElement(undefined, []),
18+
false,
19+
'identifies them as interactive elements',
20+
);
21+
22+
t.test('interactive elements', (st) => {
2223
genInteractiveElements().forEach(({ openingElement }) => {
23-
it(`should identify \`${genElementSymbol(openingElement)}\` as an interactive element`, () => {
24-
expect(isInteractiveElement(
24+
st.equal(
25+
isInteractiveElement(
2526
elementType(openingElement),
2627
openingElement.attributes,
27-
)).toBe(true);
28-
});
28+
),
29+
true,
30+
`identifies \`${genElementSymbol(openingElement)}\` as an interactive element`,
31+
);
2932
});
33+
34+
st.end();
3035
});
31-
describe('interactive role elements', () => {
36+
37+
t.test('interactive role elements', (st) => {
3238
genInteractiveRoleElements().forEach(({ openingElement }) => {
33-
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as an interactive element`, () => {
34-
expect(isInteractiveElement(
39+
st.equal(
40+
isInteractiveElement(
3541
elementType(openingElement),
3642
openingElement.attributes,
37-
)).toBe(false);
38-
});
43+
),
44+
false,
45+
`identifies \`${genElementSymbol(openingElement)}\` as an interactive element`,
46+
);
3947
});
48+
49+
st.end();
4050
});
41-
describe('non-interactive elements', () => {
51+
52+
t.test('non-interactive elements', (st) => {
4253
genNonInteractiveElements().forEach(({ openingElement }) => {
43-
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as an interactive element`, () => {
44-
expect(isInteractiveElement(
54+
st.equal(
55+
isInteractiveElement(
4556
elementType(openingElement),
4657
openingElement.attributes,
47-
)).toBe(false);
48-
});
58+
),
59+
false,
60+
`identifies \`${genElementSymbol(openingElement)}\` as an interactive element`,
61+
);
4962
});
63+
64+
st.end();
5065
});
51-
describe('non-interactive role elements', () => {
66+
67+
t.test('non-interactive role elements', (st) => {
5268
genNonInteractiveRoleElements().forEach(({ openingElement }) => {
53-
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as an interactive element`, () => {
54-
expect(isInteractiveElement(
69+
st.equal(
70+
isInteractiveElement(
5571
elementType(openingElement),
5672
openingElement.attributes,
57-
)).toBe(false);
58-
});
73+
),
74+
false,
75+
`identifies \`${genElementSymbol(openingElement)}\` as an interactive element`,
76+
);
5977
});
78+
79+
st.end();
6080
});
61-
describe('indeterminate elements', () => {
81+
82+
t.test('indeterminate elements', (st) => {
6283
genIndeterminantInteractiveElements().forEach(({ openingElement }) => {
63-
it(`should NOT identify \`${openingElement.name.name}\` as an interactive element`, () => {
64-
expect(isInteractiveElement(
84+
st.equal(
85+
isInteractiveElement(
6586
elementType(openingElement),
6687
openingElement.attributes,
67-
)).toBe(false);
68-
});
69-
});
70-
});
71-
describe('JSX elements', () => {
72-
it('is not interactive', () => {
73-
expect(isInteractiveElement('CustomComponent', JSXElementMock())).toBe(false);
88+
),
89+
false,
90+
`identifies \`${genElementSymbol(openingElement)}\` as an interactive element`,
91+
);
7492
});
93+
94+
st.end();
7595
});
96+
97+
t.equal(
98+
isInteractiveElement('CustomComponent', JSXElementMock()),
99+
false,
100+
'JSX elements are not interactive',
101+
);
102+
103+
t.end();
76104
});
+38-23
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,59 @@
1-
import expect from 'expect';
1+
import test from 'tape';
22
import { elementType } from 'jsx-ast-utils';
3+
34
import isInteractiveRole from '../../../src/util/isInteractiveRole';
45
import {
56
genElementSymbol,
67
genInteractiveRoleElements,
78
genNonInteractiveRoleElements,
89
} from '../../../__mocks__/genInteractives';
910

10-
describe('isInteractiveRole', () => {
11-
describe('JSX Components (no tagName)', () => {
12-
it('should identify them as interactive role elements', () => {
13-
expect(isInteractiveRole(undefined, []))
14-
.toBe(false);
15-
});
16-
});
17-
describe('elements with a non-interactive role', () => {
11+
test('isInteractiveRole', (t) => {
12+
t.equal(
13+
isInteractiveRole(undefined, []),
14+
false,
15+
'identifies JSX Components (no tagName) as interactive role elements',
16+
);
17+
18+
t.test('elements with a non-interactive role', (st) => {
1819
genNonInteractiveRoleElements().forEach(({ openingElement }) => {
1920
const { attributes } = openingElement;
20-
it(`should not identify \`${genElementSymbol(openingElement)}\` as an interactive role element`, () => {
21-
expect(isInteractiveRole(
21+
22+
st.equal(
23+
isInteractiveRole(
2224
elementType(openingElement),
2325
attributes,
24-
)).toBe(false);
25-
});
26-
});
27-
});
28-
describe('elements without a role', () => {
29-
it('should not identify them as interactive role elements', () => {
30-
expect(isInteractiveRole('div', [])).toBe(false);
26+
),
27+
false,
28+
`does NOT identify \`${genElementSymbol(openingElement)}\` as an interactive role element`,
29+
);
3130
});
31+
32+
st.end();
3233
});
33-
describe('elements with an interactive role', () => {
34+
35+
t.equal(
36+
isInteractiveRole('div', []),
37+
false,
38+
'does NOT identify elements without a role as interactive role elements',
39+
);
40+
41+
t.test('elements with an interactive role', (st) => {
3442
genInteractiveRoleElements().forEach(({ openingElement }) => {
3543
const { attributes } = openingElement;
36-
it(`should identify \`${genElementSymbol(openingElement)}\` as an interactive role element`, () => {
37-
expect(isInteractiveRole(
44+
45+
st.equal(
46+
isInteractiveRole(
3847
elementType(openingElement),
3948
attributes,
40-
)).toBe(true);
41-
});
49+
),
50+
true,
51+
`identifies \`${genElementSymbol(openingElement)}\` as an interactive role element`,
52+
);
4253
});
54+
55+
st.end();
4356
});
57+
58+
t.end();
4459
});
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import expect from 'expect';
1+
import test from 'tape';
22
import { elementType } from 'jsx-ast-utils';
3+
34
import isNonInteractiveElement from '../../../src/util/isNonInteractiveElement';
45
import {
56
genElementSymbol,
@@ -10,61 +11,87 @@ import {
1011
genNonInteractiveRoleElements,
1112
} from '../../../__mocks__/genInteractives';
1213

13-
describe('isNonInteractiveElement', () => {
14-
describe('JSX Components (no tagName)', () => {
15-
it('should identify them as interactive elements', () => {
16-
expect(isNonInteractiveElement(undefined, []))
17-
.toBe(false);
18-
});
19-
});
20-
describe('non-interactive elements', () => {
14+
test('isNonInteractiveElement', (t) => {
15+
t.equal(
16+
isNonInteractiveElement(undefined, []),
17+
false,
18+
'identifies JSX Components (no tagName) as non-interactive elements',
19+
);
20+
21+
t.test('non-interactive elements', (st) => {
2122
genNonInteractiveElements().forEach(({ openingElement }) => {
22-
it(`should identify \`${genElementSymbol(openingElement)}\` as a non-interactive element`, () => {
23-
expect(isNonInteractiveElement(
23+
st.equal(
24+
isNonInteractiveElement(
2425
elementType(openingElement),
2526
openingElement.attributes,
26-
)).toBe(true);
27-
});
27+
),
28+
true,
29+
`identifies \`${genElementSymbol(openingElement)}\` as a non-interactive element`,
30+
);
2831
});
32+
33+
st.end();
2934
});
30-
describe('non-interactive role elements', () => {
35+
36+
t.test('non-interactive role elements', (st) => {
3137
genNonInteractiveRoleElements().forEach(({ openingElement }) => {
32-
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as a non-interactive element`, () => {
33-
expect(isNonInteractiveElement(
38+
st.equal(
39+
isNonInteractiveElement(
3440
elementType(openingElement),
3541
openingElement.attributes,
36-
)).toBe(false);
37-
});
42+
),
43+
false,
44+
`identifies \`${genElementSymbol(openingElement)}\` as a non-interactive element`,
45+
);
3846
});
47+
48+
st.end();
3949
});
40-
describe('interactive elements', () => {
50+
51+
t.test('interactive elements', (st) => {
4152
genInteractiveElements().forEach(({ openingElement }) => {
42-
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as a non-interactive element`, () => {
43-
expect(isNonInteractiveElement(
53+
st.equal(
54+
isNonInteractiveElement(
4455
elementType(openingElement),
4556
openingElement.attributes,
46-
)).toBe(false);
47-
});
57+
),
58+
false,
59+
`identifies \`${genElementSymbol(openingElement)}\` as a non-interactive element`,
60+
);
4861
});
62+
63+
st.end();
4964
});
50-
describe('interactive role elements', () => {
65+
66+
t.test('interactive role elements', (st) => {
5167
genInteractiveRoleElements().forEach(({ openingElement }) => {
52-
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as a non-interactive element`, () => {
53-
expect(isNonInteractiveElement(
68+
st.equal(
69+
isNonInteractiveElement(
5470
elementType(openingElement),
5571
openingElement.attributes,
56-
)).toBe(false);
57-
});
72+
),
73+
false,
74+
`identifies \`${genElementSymbol(openingElement)}\` as a non-interactive element`,
75+
);
5876
});
77+
78+
st.end();
5979
});
60-
describe('indeterminate elements', () => {
80+
81+
t.test('indeterminate elements', (st) => {
6182
genIndeterminantInteractiveElements().forEach(({ openingElement }) => {
62-
it(`should NOT identify \`${openingElement.name.name}\` as a non-interactive element`, () => {
63-
expect(isNonInteractiveElement(
83+
st.equal(
84+
isNonInteractiveElement(
6485
elementType(openingElement),
6586
openingElement.attributes,
66-
)).toBe(false);
67-
});
87+
),
88+
false,
89+
`identifies \`${genElementSymbol(openingElement)}\` as a non-interactive element`,
90+
);
6891
});
92+
93+
st.end();
6994
});
95+
96+
t.end();
7097
});
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,59 @@
1-
import expect from 'expect';
1+
import test from 'tape';
22
import { elementType } from 'jsx-ast-utils';
3+
34
import isNonInteractiveRole from '../../../src/util/isNonInteractiveRole';
45
import {
56
genElementSymbol,
67
genInteractiveRoleElements,
78
genNonInteractiveRoleElements,
89
} from '../../../__mocks__/genInteractives';
910

10-
describe('isNonInteractiveRole', () => {
11-
describe('JSX Components (no tagName)', () => {
12-
it('should identify them as interactive role elements', () => {
13-
expect(isNonInteractiveRole(undefined, []))
14-
.toBe(false);
15-
});
16-
});
17-
describe('elements with a non-interactive role', () => {
11+
test('isNonInteractiveRole', (t) => {
12+
t.equal(
13+
isNonInteractiveRole(undefined, []),
14+
false,
15+
'identifies JSX Components (no tagName) as non-interactive elements',
16+
);
17+
18+
t.test('elements with a non-interactive role', (st) => {
1819
genNonInteractiveRoleElements().forEach(({ openingElement }) => {
1920
const { attributes } = openingElement;
20-
it(`should identify \`${genElementSymbol(openingElement)}\` as non-interactive role element`, () => {
21-
expect(isNonInteractiveRole(
21+
22+
st.equal(
23+
isNonInteractiveRole(
2224
elementType(openingElement),
2325
attributes,
24-
)).toBe(true);
25-
});
26-
});
27-
});
28-
describe('elements without a role', () => {
29-
it('should not identify them as non-interactive role elements', () => {
30-
expect(isNonInteractiveRole('div', [])).toBe(false);
26+
),
27+
true,
28+
`identifies \`${genElementSymbol(openingElement)}\` as a non-interactive role element`,
29+
);
3130
});
31+
32+
st.end();
3233
});
33-
describe('elements with an interactive role', () => {
34+
35+
t.equal(
36+
isNonInteractiveRole('div', []),
37+
false,
38+
'does NOT identify elements without a role as non-interactive role elements',
39+
);
40+
41+
t.test('elements with an interactive role', (st) => {
3442
genInteractiveRoleElements().forEach(({ openingElement }) => {
3543
const { attributes } = openingElement;
36-
it(`should NOT identify \`${genElementSymbol(openingElement)}\` as a non-interactive role element`, () => {
37-
expect(isNonInteractiveRole(
44+
45+
st.equal(
46+
isNonInteractiveRole(
3847
elementType(openingElement),
3948
attributes,
40-
)).toBe(false);
41-
});
49+
),
50+
false,
51+
`does NOT identify \`${genElementSymbol(openingElement)}\` as a non-interactive role element`,
52+
);
4253
});
54+
55+
st.end();
4356
});
57+
58+
t.end();
4459
});
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import isNonLiteralProperty from '../../../src/util/isNonLiteralProperty';
34
import IdentifierMock from '../../../__mocks__/IdentifierMock';
45
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
@@ -10,35 +11,42 @@ const theProp = 'theProp';
1011

1112
const spread = JSXSpreadAttributeMock('theSpread');
1213

13-
describe('isNonLiteralProperty', () => {
14-
describe('elements without the property', () => {
15-
it('should not identify them as non-literal role elements', () => {
16-
expect(isNonLiteralProperty([], theProp)).toBe(false);
17-
});
18-
});
19-
describe('elements with a literal property', () => {
20-
it('should not identify them as non-literal role elements without spread operator', () => {
21-
expect(isNonLiteralProperty([JSXAttributeMock(theProp, LiteralMock('theRole'))], theProp)).toBe(false);
22-
});
23-
it('should not identify them as non-literal role elements with spread operator', () => {
24-
expect(isNonLiteralProperty([spread, JSXAttributeMock(theProp, LiteralMock('theRole'))], theProp)).toBe(false);
25-
});
26-
});
27-
describe('elements with a JSXText property', () => {
28-
it('should not identify them as non-literal role elements', () => {
29-
expect(isNonLiteralProperty([JSXAttributeMock(theProp, JSXTextMock('theRole'))], theProp)).toBe(false);
30-
});
31-
});
32-
describe('elements with a property of undefined', () => {
33-
it('should not identify them as non-literal role elements', () => {
34-
const undefinedExpression = IdentifierMock('undefined');
35-
expect(isNonLiteralProperty([JSXAttributeMock(theProp, undefinedExpression)], theProp)).toBe(false);
36-
});
37-
});
38-
describe('elements with a expression property', () => {
39-
it('should identify them as non-literal role elements', () => {
40-
const identifierExpression = IdentifierMock('theIdentifier');
41-
expect(isNonLiteralProperty([JSXAttributeMock(theProp, identifierExpression)], theProp)).toBe(true);
42-
});
43-
});
14+
test('isNonLiteralProperty', (t) => {
15+
t.equal(
16+
isNonLiteralProperty([], theProp),
17+
false,
18+
'does not identify them as non-literal role elements',
19+
);
20+
21+
t.equal(
22+
isNonLiteralProperty([JSXAttributeMock(theProp, LiteralMock('theRole'))], theProp),
23+
false,
24+
'does not identify elements with a literal property as non-literal role elements without spread operator',
25+
);
26+
27+
t.equal(
28+
isNonLiteralProperty([spread, JSXAttributeMock(theProp, LiteralMock('theRole'))], theProp),
29+
false,
30+
'does not identify elements with a literal property as non-literal role elements with spread operator',
31+
);
32+
33+
t.equal(
34+
isNonLiteralProperty([JSXAttributeMock(theProp, JSXTextMock('theRole'))], theProp),
35+
false,
36+
'identifies elements with a JSXText property as non-literal role elements',
37+
);
38+
39+
t.equal(
40+
isNonLiteralProperty([JSXAttributeMock(theProp, IdentifierMock('undefined'))], theProp),
41+
false,
42+
'does not identify elements with a property of undefined as non-literal role elements',
43+
);
44+
45+
t.equal(
46+
isNonLiteralProperty([JSXAttributeMock(theProp, IdentifierMock('theIdentifier'))], theProp),
47+
true,
48+
'identifies elements with an expression property as non-literal role elements',
49+
);
50+
51+
t.end();
4452
});
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,55 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import isSemanticRoleElement from '../../../src/util/isSemanticRoleElement';
34
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
45

5-
describe('isSemanticRoleElement', () => {
6-
it('should identify semantic role elements', () => {
7-
expect(isSemanticRoleElement('input', [
6+
test('isSemanticRoleElement', (t) => {
7+
t.equal(
8+
isSemanticRoleElement('input', [
89
JSXAttributeMock('type', 'checkbox'),
910
JSXAttributeMock('role', 'switch'),
10-
])).toBe(true);
11-
});
12-
it('should reject non-semantic role elements', () => {
13-
expect(isSemanticRoleElement('input', [
14-
JSXAttributeMock('type', 'radio'),
15-
JSXAttributeMock('role', 'switch'),
16-
])).toBe(false);
17-
expect(isSemanticRoleElement('input', [
18-
JSXAttributeMock('type', 'text'),
19-
JSXAttributeMock('role', 'combobox'),
20-
])).toBe(false);
21-
expect(isSemanticRoleElement('button', [
22-
JSXAttributeMock('role', 'switch'),
23-
JSXAttributeMock('aria-pressed', 'true'),
24-
])).toBe(false);
25-
expect(isSemanticRoleElement('input', [
26-
JSXAttributeMock('role', 'switch'),
27-
])).toBe(false);
11+
]),
12+
true,
13+
'identifies semantic role elements',
14+
);
15+
16+
t.test('rejects non-semantics role elements', (st) => {
17+
st.equal(
18+
isSemanticRoleElement('input', [
19+
JSXAttributeMock('type', 'radio'),
20+
JSXAttributeMock('role', 'switch'),
21+
]),
22+
false,
23+
);
24+
25+
st.equal(
26+
isSemanticRoleElement('input', [
27+
JSXAttributeMock('type', 'text'),
28+
JSXAttributeMock('role', 'combobox'),
29+
]),
30+
false,
31+
);
32+
33+
st.equal(
34+
isSemanticRoleElement('button', [
35+
JSXAttributeMock('role', 'switch'),
36+
JSXAttributeMock('aria-pressed', 'true'),
37+
]),
38+
false,
39+
);
40+
41+
st.equal(
42+
isSemanticRoleElement('input', [
43+
JSXAttributeMock('role', 'switch'),
44+
]),
45+
false,
46+
);
47+
48+
st.end();
2849
});
29-
it('should not throw on JSXSpreadAttribute', () => {
30-
expect(() => {
50+
51+
t.doesNotThrow(
52+
() => {
3153
isSemanticRoleElement('input', [
3254
JSXAttributeMock('type', 'checkbox'),
3355
JSXAttributeMock('role', 'checkbox'),
@@ -42,6 +64,9 @@ describe('isSemanticRoleElement', () => {
4264
},
4365
},
4466
]);
45-
}).not.toThrow();
46-
});
67+
},
68+
'does not throw on JSXSpreadAttribute',
69+
);
70+
71+
t.end();
4772
});
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,87 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import mayContainChildComponent from '../../../src/util/mayContainChildComponent';
34
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
45
import JSXElementMock from '../../../__mocks__/JSXElementMock';
56
import JSXExpressionContainerMock from '../../../__mocks__/JSXExpressionContainerMock';
67

7-
describe('mayContainChildComponent', () => {
8-
describe('no FancyComponent', () => {
9-
it('should return false', () => {
10-
expect(mayContainChildComponent(
8+
test('mayContainChildComponent', (t) => {
9+
t.equal(
10+
mayContainChildComponent(
11+
JSXElementMock('div', [], [
1112
JSXElementMock('div', [], [
12-
JSXElementMock('div', [], [
13+
JSXElementMock('span', [], []),
14+
JSXElementMock('span', [], [
1315
JSXElementMock('span', [], []),
1416
JSXElementMock('span', [], [
1517
JSXElementMock('span', [], []),
16-
JSXElementMock('span', [], [
17-
JSXElementMock('span', [], []),
18-
]),
1918
]),
2019
]),
21-
JSXElementMock('span', [], []),
22-
JSXElementMock('img', [
23-
JSXAttributeMock('src', 'some/path'),
24-
]),
2520
]),
26-
'FancyComponent',
27-
5,
28-
)).toBe(false);
29-
});
30-
});
31-
describe('contains an indicated component', () => {
32-
it('should return true', () => {
33-
expect(mayContainChildComponent(
21+
JSXElementMock('span', [], []),
22+
JSXElementMock('img', [
23+
JSXAttributeMock('src', 'some/path'),
24+
]),
25+
]),
26+
'FancyComponent',
27+
5,
28+
),
29+
false,
30+
'no FancyComponent returns false',
31+
);
32+
33+
t.test('contains an indicated component', (st) => {
34+
st.equal(
35+
mayContainChildComponent(
3436
JSXElementMock('div', [], [
3537
JSXElementMock('input'),
3638
]),
3739
'input',
38-
)).toBe(true);
39-
});
40-
it('should return true', () => {
41-
expect(mayContainChildComponent(
40+
),
41+
true,
42+
'returns true',
43+
);
44+
45+
st.equal(
46+
mayContainChildComponent(
4247
JSXElementMock('div', [], [
4348
JSXElementMock('FancyComponent'),
4449
]),
4550
'FancyComponent',
46-
)).toBe(true);
47-
});
48-
it('FancyComponent is outside of default depth, should return false', () => {
49-
expect(mayContainChildComponent(
51+
),
52+
true,
53+
'returns true',
54+
);
55+
56+
st.equal(
57+
mayContainChildComponent(
5058
JSXElementMock('div', [], [
5159
JSXElementMock('div', [], [
5260
JSXElementMock('FancyComponent'),
5361
]),
5462
]),
5563
'FancyComponent',
56-
)).toBe(false);
57-
});
58-
it('FancyComponent is inside of custom depth, should return true', () => {
59-
expect(mayContainChildComponent(
64+
),
65+
false,
66+
'FancyComponent is outside of default depth, should return false',
67+
);
68+
69+
st.equal(
70+
mayContainChildComponent(
6071
JSXElementMock('div', [], [
6172
JSXElementMock('div', [], [
6273
JSXElementMock('FancyComponent'),
6374
]),
6475
]),
6576
'FancyComponent',
6677
2,
67-
)).toBe(true);
68-
});
69-
it('deep nesting, should return true', () => {
70-
expect(mayContainChildComponent(
78+
),
79+
true,
80+
'FancyComponent is inside of custom depth, should return true',
81+
);
82+
83+
st.equal(
84+
mayContainChildComponent(
7185
JSXElementMock('div', [], [
7286
JSXElementMock('div', [], [
7387
JSXElementMock('span', [], []),
@@ -89,90 +103,117 @@ describe('mayContainChildComponent', () => {
89103
]),
90104
'FancyComponent',
91105
6,
92-
)).toBe(true);
93-
});
94-
});
95-
describe('Intederminate situations', () => {
96-
describe('expression container children', () => {
97-
it('should return true', () => {
98-
expect(mayContainChildComponent(
99-
JSXElementMock('div', [], [
100-
JSXExpressionContainerMock('mysteryBox'),
101-
]),
102-
'FancyComponent',
103-
)).toBe(true);
104-
});
105-
});
106+
),
107+
true,
108+
'deep nesting, returns true',
109+
);
110+
111+
st.end();
106112
});
107113

108-
describe('Glob name matching', () => {
109-
describe('component name contains question mark ? - match any single character', () => {
110-
it('should return true', () => {
111-
expect(mayContainChildComponent(
112-
JSXElementMock('div', [], [
113-
JSXElementMock('FancyComponent'),
114-
]),
115-
'Fanc?Co??onent',
116-
)).toBe(true);
117-
});
118-
it('should return false', () => {
119-
expect(mayContainChildComponent(
120-
JSXElementMock('div', [], [
121-
JSXElementMock('FancyComponent'),
122-
]),
123-
'FancyComponent?',
124-
)).toBe(false);
125-
});
126-
});
114+
t.equal(
115+
mayContainChildComponent(
116+
JSXElementMock('div', [], [
117+
JSXExpressionContainerMock('mysteryBox'),
118+
]),
119+
'FancyComponent',
120+
),
121+
true,
122+
'Intederminate situations + expression container children - returns true',
123+
);
124+
125+
t.test('Glob name matching - component name contains question mark ? - match any single character', (st) => {
126+
st.equal(
127+
mayContainChildComponent(
128+
JSXElementMock('div', [], [
129+
JSXElementMock('FancyComponent'),
130+
]),
131+
'Fanc?Co??onent',
132+
),
133+
true,
134+
'returns true',
135+
);
127136

128-
describe('component name contains asterisk * - match zero or more characters', () => {
129-
it('should return true', () => {
130-
expect(mayContainChildComponent(
137+
st.equal(
138+
mayContainChildComponent(
139+
JSXElementMock('div', [], [
140+
JSXElementMock('FancyComponent'),
141+
]),
142+
'FancyComponent?',
143+
),
144+
false,
145+
'returns false',
146+
);
147+
148+
st.test('component name contains asterisk * - match zero or more characters', (s2t) => {
149+
s2t.equal(
150+
mayContainChildComponent(
131151
JSXElementMock('div', [], [
132152
JSXElementMock('FancyComponent'),
133153
]),
134154
'Fancy*',
135-
)).toBe(true);
136-
});
137-
it('should return true', () => {
138-
expect(mayContainChildComponent(
155+
),
156+
true,
157+
'returns true',
158+
);
159+
160+
s2t.equal(
161+
mayContainChildComponent(
139162
JSXElementMock('div', [], [
140163
JSXElementMock('FancyComponent'),
141164
]),
142165
'*Component',
143-
)).toBe(true);
144-
});
145-
it('should return true', () => {
146-
expect(mayContainChildComponent(
166+
),
167+
true,
168+
'returns true',
169+
);
170+
171+
s2t.equal(
172+
mayContainChildComponent(
147173
JSXElementMock('div', [], [
148174
JSXElementMock('FancyComponent'),
149175
]),
150176
'Fancy*C*t',
151-
)).toBe(true);
152-
});
177+
),
178+
true,
179+
'returns true',
180+
);
181+
182+
s2t.end();
153183
});
184+
185+
st.end();
154186
});
155187

156-
describe('using a custom elementType function', () => {
157-
it('should return true when the custom elementType returns the proper name', () => {
158-
expect(mayContainChildComponent(
188+
t.test('using a custom elementType function', (st) => {
189+
st.equal(
190+
mayContainChildComponent(
159191
JSXElementMock('div', [], [
160192
JSXElementMock('CustomInput'),
161193
]),
162194
'input',
163195
2,
164196
() => 'input',
165-
)).toBe(true);
166-
});
167-
it('should return false when the custom elementType returns a wrong name', () => {
168-
expect(mayContainChildComponent(
197+
),
198+
true,
199+
'returns true when the custom elementType returns the proper name',
200+
);
201+
202+
st.equal(
203+
mayContainChildComponent(
169204
JSXElementMock('div', [], [
170205
JSXElementMock('CustomInput'),
171206
]),
172207
'input',
173208
2,
174209
() => 'button',
175-
)).toBe(false);
176-
});
210+
),
211+
false,
212+
'returns false when the custom elementType returns a wrong name',
213+
);
214+
215+
st.end();
177216
});
217+
218+
t.end();
178219
});
+179-109
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import mayHaveAccessibleLabel from '../../../src/util/mayHaveAccessibleLabel';
34
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
45
import JSXElementMock from '../../../__mocks__/JSXElementMock';
@@ -7,117 +8,165 @@ import JSXSpreadAttributeMock from '../../../__mocks__/JSXSpreadAttributeMock';
78
import JSXTextMock from '../../../__mocks__/JSXTextMock';
89
import LiteralMock from '../../../__mocks__/LiteralMock';
910

10-
describe('mayHaveAccessibleLabel', () => {
11-
describe('no label', () => {
12-
it('should return false', () => {
13-
expect(mayHaveAccessibleLabel(
11+
test('mayHaveAccessibleLabel', (t) => {
12+
t.equal(
13+
mayHaveAccessibleLabel(
14+
JSXElementMock('div', [], [
1415
JSXElementMock('div', [], [
15-
JSXElementMock('div', [], [
16+
JSXElementMock('span', [], []),
17+
JSXElementMock('span', [], [
1618
JSXElementMock('span', [], []),
1719
JSXElementMock('span', [], [
1820
JSXElementMock('span', [], []),
19-
JSXElementMock('span', [], [
20-
JSXElementMock('span', [], []),
21-
]),
2221
]),
2322
]),
24-
JSXElementMock('span', [], []),
25-
JSXElementMock('img', [
26-
JSXAttributeMock('src', 'some/path'),
27-
]),
2823
]),
29-
5,
30-
)).toBe(false);
31-
});
32-
});
33-
describe('label via attributes', () => {
34-
it('aria-label, should return true', () => {
35-
expect(mayHaveAccessibleLabel(JSXElementMock('div', [
24+
JSXElementMock('span', [], []),
25+
JSXElementMock('img', [
26+
JSXAttributeMock('src', 'some/path'),
27+
]),
28+
]),
29+
5,
30+
),
31+
false,
32+
'no label returns false',
33+
);
34+
35+
t.test('label via attributes', (st) => {
36+
st.equal(
37+
mayHaveAccessibleLabel(JSXElementMock('div', [
3638
JSXAttributeMock('aria-label', 'A delicate label'),
37-
], []))).toBe(true);
38-
});
39-
it('aria-label without content, should return false', () => {
40-
expect(mayHaveAccessibleLabel(JSXElementMock('div', [
39+
], [])),
40+
true,
41+
'aria-label returns true',
42+
);
43+
44+
st.equal(
45+
mayHaveAccessibleLabel(JSXElementMock('div', [
4146
JSXAttributeMock('aria-label', ''),
42-
], []))).toBe(false);
43-
});
44-
it('aria-label with only whitespace, should return false', () => {
45-
expect(mayHaveAccessibleLabel(JSXElementMock('div', [
47+
], [])),
48+
false,
49+
'aria-label without content returns false',
50+
);
51+
52+
st.equal(
53+
mayHaveAccessibleLabel(JSXElementMock('div', [
4654
JSXAttributeMock('aria-label', ' '),
47-
], []))).toBe(false);
48-
expect(mayHaveAccessibleLabel(JSXElementMock('div', [
55+
], [])),
56+
false,
57+
'aria-label with only spaces whitespace, should return false',
58+
);
59+
st.equal(
60+
mayHaveAccessibleLabel(JSXElementMock('div', [
4961
JSXAttributeMock('aria-label', '\n'),
50-
], []))).toBe(false);
51-
});
52-
it('aria-labelledby, should return true', () => {
53-
expect(mayHaveAccessibleLabel(JSXElementMock('div', [
62+
], [])),
63+
false,
64+
'aria-label with only newline whitespace, should return false',
65+
);
66+
67+
st.equal(
68+
mayHaveAccessibleLabel(JSXElementMock('div', [
5469
JSXAttributeMock('aria-labelledby', 'elementId'),
55-
], []))).toBe(true);
56-
});
57-
it('aria-labelledby without content, should return false', () => {
58-
expect(mayHaveAccessibleLabel(JSXElementMock('div', [
70+
], [])),
71+
true,
72+
'aria-labelledby returns true',
73+
);
74+
75+
st.equal(
76+
mayHaveAccessibleLabel(JSXElementMock('div', [
5977
JSXAttributeMock('aria-labelledby', ''),
60-
], []))).toBe(false);
61-
});
62-
it('aria-labelledby with an expression container, should return true', () => {
63-
expect(mayHaveAccessibleLabel(JSXElementMock('div', [
78+
], [])),
79+
false,
80+
'aria-labelledby without content returns false',
81+
);
82+
83+
st.equal(
84+
mayHaveAccessibleLabel(JSXElementMock('div', [
6485
JSXAttributeMock('aria-labelledby', 'elementId', true),
65-
], []))).toBe(true);
66-
});
86+
], [])),
87+
true,
88+
'aria-labelledby with an expression container, should return true',
89+
);
90+
91+
st.end();
6792
});
68-
describe('label via custom label attribute', () => {
69-
let customLabelProp;
70-
beforeEach(() => {
71-
customLabelProp = 'cowbell';
72-
});
73-
it('aria-label, should return true', () => {
74-
expect(mayHaveAccessibleLabel(
93+
94+
t.test('label via custom label attribute', (st) => {
95+
const customLabelProp = 'cowbell';
96+
97+
st.equal(
98+
mayHaveAccessibleLabel(
7599
JSXElementMock('div', [
76100
JSXAttributeMock(customLabelProp, 'A delicate label'),
77101
], []),
78102
1,
79103
[customLabelProp],
80-
)).toBe(true);
81-
});
104+
),
105+
true,
106+
'aria-label returns true',
107+
);
108+
109+
st.end();
82110
});
83-
describe('text label', () => {
84-
it('Literal text, should return true', () => {
85-
expect(mayHaveAccessibleLabel(JSXElementMock('div', [], [
111+
112+
t.test('text label', (st) => {
113+
st.equal(
114+
mayHaveAccessibleLabel(JSXElementMock('div', [], [
86115
LiteralMock('A fancy label'),
87-
]))).toBe(true);
88-
});
89-
it('Literal whitespace, should return false', () => {
90-
expect(mayHaveAccessibleLabel(JSXElementMock('div', [], [
116+
])),
117+
true,
118+
'Literal text, returns true',
119+
);
120+
121+
st.equal(
122+
mayHaveAccessibleLabel(JSXElementMock('div', [], [
91123
LiteralMock(' '),
92-
]))).toBe(false);
93-
expect(mayHaveAccessibleLabel(JSXElementMock('div', [], [
124+
])),
125+
false,
126+
'Literal spaces whitespace, returns false',
127+
);
128+
129+
st.equal(
130+
mayHaveAccessibleLabel(JSXElementMock('div', [], [
94131
LiteralMock('\n'),
95-
]))).toBe(false);
96-
});
97-
it('JSXText, should return true', () => {
98-
expect(mayHaveAccessibleLabel(JSXElementMock('div', [], [
132+
])),
133+
false,
134+
'Literal newline whitespace, returns false',
135+
);
136+
137+
st.equal(
138+
mayHaveAccessibleLabel(JSXElementMock('div', [], [
99139
JSXTextMock('A fancy label'),
100-
]))).toBe(true);
101-
});
102-
it('label is outside of default depth, should return false', () => {
103-
expect(mayHaveAccessibleLabel(JSXElementMock('div', [], [
140+
])),
141+
true,
142+
'JSXText, returns true',
143+
);
144+
145+
st.equal(
146+
mayHaveAccessibleLabel(JSXElementMock('div', [], [
104147
JSXElementMock('div', [], [
105148
JSXTextMock('A fancy label'),
106149
]),
107-
]))).toBe(false);
108-
});
109-
it('label is inside of custom depth, should return true', () => {
110-
expect(mayHaveAccessibleLabel(
150+
])),
151+
false,
152+
'label is outside of default depth, returns false',
153+
);
154+
155+
st.equal(
156+
mayHaveAccessibleLabel(
111157
JSXElementMock('div', [], [
112158
JSXElementMock('div', [], [
113159
JSXTextMock('A fancy label'),
114160
]),
115161
]),
116162
2,
117-
)).toBe(true);
118-
});
119-
it('deep nesting, should return true', () => {
120-
expect(mayHaveAccessibleLabel(
163+
),
164+
true,
165+
'label is inside of custom depth, returns true',
166+
);
167+
168+
st.equal(
169+
mayHaveAccessibleLabel(
121170
JSXElementMock('div', [], [
122171
JSXElementMock('div', [], [
123172
JSXElementMock('span', [], []),
@@ -138,49 +187,70 @@ describe('mayHaveAccessibleLabel', () => {
138187
]),
139188
]),
140189
6,
141-
)).toBe(true);
142-
});
190+
),
191+
true,
192+
'deep nesting, returns true',
193+
);
194+
195+
st.end();
143196
});
144-
describe('image content', () => {
145-
it('without alt, should return true', () => {
146-
expect(mayHaveAccessibleLabel(JSXElementMock('div', [], [
197+
198+
t.test('image content', (st) => {
199+
st.equal(
200+
mayHaveAccessibleLabel(JSXElementMock('div', [], [
147201
JSXElementMock('img', [
148202
JSXAttributeMock('src', 'some/path'),
149203
]),
150-
]))).toBe(false);
151-
});
152-
it('with alt, should return true', () => {
153-
expect(mayHaveAccessibleLabel(JSXElementMock('div', [], [
204+
])),
205+
false,
206+
'without alt, returns true',
207+
);
208+
209+
st.equal(
210+
mayHaveAccessibleLabel(JSXElementMock('div', [], [
154211
JSXElementMock('img', [
155212
JSXAttributeMock('src', 'some/path'),
156213
JSXAttributeMock('alt', 'A sensible label'),
157214
]),
158-
]))).toBe(true);
159-
});
160-
it('with aria-label, should return true', () => {
161-
expect(mayHaveAccessibleLabel(JSXElementMock('div', [], [
215+
])),
216+
true,
217+
'with alt, returns true',
218+
);
219+
220+
st.equal(
221+
mayHaveAccessibleLabel(JSXElementMock('div', [], [
162222
JSXElementMock('img', [
163223
JSXAttributeMock('src', 'some/path'),
164224
JSXAttributeMock('aria-label', 'A sensible label'),
165225
]),
166-
]))).toBe(true);
167-
});
226+
])),
227+
true,
228+
'with aria-label, returns true',
229+
);
230+
231+
st.end();
168232
});
169-
describe('Intederminate situations', () => {
170-
describe('expression container children', () => {
171-
it('should return true', () => {
172-
expect(mayHaveAccessibleLabel(JSXElementMock('div', [], [
173-
JSXExpressionContainerMock('mysteryBox'),
174-
]))).toBe(true);
175-
});
176-
});
177-
describe('spread operator in attributes', () => {
178-
it('should return true', () => {
179-
expect(mayHaveAccessibleLabel(JSXElementMock('div', [
180-
JSXAttributeMock('style', 'some-junk'),
181-
JSXSpreadAttributeMock('props'),
182-
], []))).toBe(true);
183-
});
184-
});
233+
234+
t.test('Intederminate situations', (st) => {
235+
st.equal(
236+
mayHaveAccessibleLabel(JSXElementMock('div', [], [
237+
JSXExpressionContainerMock('mysteryBox'),
238+
])),
239+
true,
240+
'expression container children, returns true',
241+
);
242+
243+
st.equal(
244+
mayHaveAccessibleLabel(JSXElementMock('div', [
245+
JSXAttributeMock('style', 'some-junk'),
246+
JSXSpreadAttributeMock('props'),
247+
], [])),
248+
true,
249+
'spread operator in attributes, returns true',
250+
);
251+
252+
st.end();
185253
});
254+
255+
t.end();
186256
});
+65-60
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,93 @@
11
import { version as eslintVersion } from 'eslint/package.json';
2-
import expect from 'expect';
2+
import test from 'tape';
33
import semver from 'semver';
4+
45
import parserOptionsMapper from '../../__util__/parserOptionsMapper';
56

67
const usingLegacy = semver.major(eslintVersion) < 9;
78

8-
describe('parserOptionsMapper', () => {
9-
it('should return an test case object', () => {
10-
const testCase = {
9+
test('parserOptionsMapper', (t) => {
10+
const expectedResult = usingLegacy
11+
? {
1112
code: '<div />',
1213
errors: [],
1314
options: {},
14-
};
15-
16-
const expectedResult = usingLegacy
17-
? {
18-
code: '<div />',
19-
errors: [],
20-
options: {},
15+
parserOptions: {
16+
ecmaVersion: 2018,
17+
ecmaFeatures: {
18+
experimentalObjectRestSpread: true,
19+
jsx: true,
20+
},
21+
},
22+
settings: {},
23+
}
24+
: {
25+
code: '<div />',
26+
errors: [],
27+
options: {},
28+
languageOptions: {
29+
ecmaVersion: 'latest',
2130
parserOptions: {
22-
ecmaVersion: 2018,
2331
ecmaFeatures: {
2432
experimentalObjectRestSpread: true,
2533
jsx: true,
2634
},
2735
},
28-
settings: {},
29-
}
30-
: {
31-
code: '<div />',
32-
errors: [],
33-
options: {},
34-
languageOptions: {
35-
ecmaVersion: 'latest',
36-
parserOptions: {
37-
ecmaFeatures: {
38-
experimentalObjectRestSpread: true,
39-
jsx: true,
40-
},
41-
},
36+
},
37+
settings: {},
38+
};
39+
40+
t.deepEqual(
41+
parserOptionsMapper({
42+
code: '<div />',
43+
errors: [],
44+
options: {},
45+
}),
46+
expectedResult,
47+
'returns a test case object',
48+
);
49+
50+
const expectedResult2 = usingLegacy
51+
? {
52+
code: '<div />',
53+
errors: [],
54+
options: {},
55+
parserOptions: {
56+
ecmaVersion: 5,
57+
ecmaFeatures: {
58+
experimentalObjectRestSpread: true,
59+
jsx: true,
4260
},
43-
settings: {},
44-
};
45-
expect(parserOptionsMapper(testCase)).toEqual(expectedResult);
46-
});
47-
it('should allow for overriding parserOptions', () => {
48-
const testCase = {
61+
},
62+
settings: {},
63+
}
64+
: {
4965
code: '<div />',
5066
errors: [],
5167
options: {},
5268
languageOptions: {
5369
ecmaVersion: 5,
54-
},
55-
};
56-
57-
const expectedResult = usingLegacy
58-
? {
59-
code: '<div />',
60-
errors: [],
61-
options: {},
6270
parserOptions: {
63-
ecmaVersion: 5,
6471
ecmaFeatures: {
6572
experimentalObjectRestSpread: true,
6673
jsx: true,
6774
},
6875
},
69-
settings: {},
70-
}
71-
: {
72-
code: '<div />',
73-
errors: [],
74-
options: {},
75-
languageOptions: {
76-
ecmaVersion: 5,
77-
parserOptions: {
78-
ecmaFeatures: {
79-
experimentalObjectRestSpread: true,
80-
jsx: true,
81-
},
82-
},
83-
},
84-
settings: {},
85-
};
86-
expect(parserOptionsMapper(testCase)).toEqual(expectedResult);
87-
});
76+
},
77+
settings: {},
78+
};
79+
t.deepEqual(
80+
parserOptionsMapper({
81+
code: '<div />',
82+
errors: [],
83+
options: {},
84+
languageOptions: {
85+
ecmaVersion: 5,
86+
},
87+
}),
88+
expectedResult2,
89+
'allows for overriding parserOptions',
90+
);
91+
92+
t.end();
8893
});

‎__tests__/src/util/schemas-test.js

+25-19
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
1-
import expect from 'expect';
1+
import test from 'tape';
2+
23
import { generateObjSchema, arraySchema, enumArraySchema } from '../../../src/util/schemas';
34

4-
describe('schemas', () => {
5-
it('should generate an object schema with correct properties', () => {
5+
test('schemas', (t) => {
6+
t.test('should generate an object schema with correct properties', (st) => {
67
const schema = generateObjSchema({
78
foo: 'bar',
89
baz: arraySchema,
910
});
1011
const properties = schema.properties || {};
1112

12-
expect(properties.foo).toEqual(properties.foo, 'bar');
13-
expect(properties.baz.type).toEqual('array');
14-
});
15-
describe('enumArraySchema', () => {
16-
it('works with no arguments', () => {
17-
expect(enumArraySchema()).toEqual({
18-
additionalItems: false,
19-
items: {
20-
enum: [],
21-
type: 'string',
22-
},
23-
minItems: 0,
24-
type: 'array',
25-
uniqueItems: true,
26-
});
27-
});
13+
st.deepEqual(properties.foo, properties.foo, 'bar');
14+
st.deepEqual(properties.baz.type, 'array');
15+
16+
st.end();
2817
});
18+
19+
t.deepEqual(
20+
enumArraySchema(),
21+
{
22+
additionalItems: false,
23+
items: {
24+
enum: [],
25+
type: 'string',
26+
},
27+
minItems: 0,
28+
type: 'array',
29+
uniqueItems: true,
30+
},
31+
'enumArraySchema works with no arguments',
32+
);
33+
34+
t.end();
2935
});

‎package.json

+5-35
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@
2424
"lint:fix": "npm run lint -- --fix",
2525
"lint": "npx eslint@8 --ext=js,mjs,cjs,ts,tsx .",
2626
"prepublish": "not-in-publish || npm run prepublishOnly",
27-
"prepublishOnly": "safe-publish-latest && npm run lint && npm run flow && npm run jest",
27+
"prepublishOnly": "safe-publish-latest && npm run lint && npm run flow && npm run tests-only",
2828
"pretest": "npm run lint:fix && npm run flow",
29-
"test": "npm run jest",
29+
"test": "npm run tests-only",
30+
"tests-only": "tape --require=@babel/register '__tests__/**/*.js'",
3031
"posttest": "npx npm@'>=10.2' audit --production",
31-
"test:ci": "npm run jest -- --ci --runInBand",
3232
"pretest:examples": "npm run build",
3333
"test:examples": "npm run test-example:legacy && npm run test-example:flat-esm && npm run test-example:flat-cjs",
3434
"test-example:legacy": "cd examples/legacy && npm install && npm run lint",
3535
"test-example:flat-esm": "cd examples/flat-esm && npm install && npm run lint",
3636
"test-example:flat-cjs": "cd examples/flat-cjs && npm install && npm run lint",
37-
"jest": "jest --coverage __tests__",
3837
"pregenerate-list-of-rules": "npm run build",
3938
"generate-list-of-rules": "eslint-doc-generator --rule-doc-title-format prefix-name --rule-doc-section-options false --config-emoji recommended,☑️ --ignore-config flat/recommended --ignore-config flat/strict",
4039
"generate-list-of-rules:check": "npm run generate-list-of-rules -- --check",
@@ -51,19 +50,16 @@
5150
"babel-jest": "^24.9.0",
5251
"babel-plugin-add-module-exports": "^1.0.4",
5352
"babel-preset-airbnb": "^5.0.0",
54-
"core-js": "^3.38.1",
5553
"eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9",
5654
"eslint-config-airbnb-base": "^15.0.0",
5755
"eslint-doc-generator": "^1.7.1",
5856
"eslint-plugin-eslint-plugin": "^4.3.0",
5957
"eslint-plugin-flowtype": "^5.8.0 || ^8.0.3",
6058
"eslint-plugin-import": "^2.29.1",
6159
"estraverse": "^5.3.0",
62-
"expect": "^24.9.0",
6360
"flow-bin": "^0.147.0",
6461
"in-publish": "^2.0.1",
6562
"jackspeak": "=2.1.1",
66-
"jest": "^24.9.0",
6763
"jscodeshift": "^0.7.1",
6864
"minimist": "^1.2.8",
6965
"npmignore": "^0.3.1",
@@ -72,6 +68,7 @@
7268
"rimraf": "^3.0.2",
7369
"safe-publish-latest": "^2.0.0",
7470
"semver": "^6.3.1",
71+
"tape": "^5.8.1",
7572
"to-ast": "^1.0.0"
7673
},
7774
"engines": {
@@ -99,32 +96,6 @@
9996
"peerDependencies": {
10097
"eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9"
10198
},
102-
"jest": {
103-
"coverageReporters": [
104-
"lcov",
105-
"json",
106-
"html"
107-
],
108-
"coverageDirectory": "coverage",
109-
"roots": [
110-
"__tests__"
111-
],
112-
"testPathIgnorePatterns": [
113-
"__tests__/__util__/"
114-
],
115-
"testEnvironment": "node",
116-
"moduleNameMapper": {
117-
"@eslint/config-array": "<rootDir>/node_modules/@eslint/config-array/dist/cjs/index.cjs",
118-
"@eslint/object-schema": "<rootDir>/node_modules/@eslint/object-schema/dist/cjs/index.cjs",
119-
"node:assert": "<rootDir>/__tests__/__util__/nodeReexports/assert.js",
120-
"node:fs/promises": "<rootDir>/__tests__/__util__/nodeReexports/fs-promises.js",
121-
"node:fs": "<rootDir>/__tests__/__util__/nodeReexports/fs.js",
122-
"node:path": "<rootDir>/__tests__/__util__/nodeReexports/path.js",
123-
"node:url": "<rootDir>/__tests__/__util__/nodeReexports/url.js",
124-
"node:util": "<rootDir>/__tests__/__util__/nodeReexports/util.js"
125-
},
126-
"setupFilesAfterEnv": ["<rootDir>/setup.jest.js"]
127-
},
12899
"auto-changelog": {
129100
"output": "CHANGELOG.md",
130101
"template": "keepachangelog",
@@ -144,8 +115,7 @@
144115
"/flow",
145116
"scripts/",
146117
"CONTRIBUTING.md",
147-
"/examples",
148-
"setup.jest.js"
118+
"/examples"
149119
]
150120
}
151121
}

‎scripts/boilerplate/test.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
const testBoilerplate = (name, author, description) => `/* eslint-env jest */
2-
/**
1+
const testBoilerplate = (name, author, description) => `/**
32
* @fileoverview ${description}
43
* @author ${author}
54
*/

‎setup.jest.js

-2
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.