Skip to content

Commit cad5c6a

Browse files
committed
[Tests] switch from jest to tape
1 parent 3a89d8c commit cad5c6a

11 files changed

+4758
-5820
lines changed

.eslintrc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@
2525
],
2626
"extends": [
2727
"eslint:recommended",
28-
"plugin:jest/recommended"
2928
],
3029
"env": {
31-
"mocha": true,
3230
"node": true
3331
}
3432
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ node_modules/
22
lib/
33
reports/
44
docs/
5+
.nyc_output/
6+
coverage/

.nycrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"all": true,
3+
"check-coverage": false,
4+
"reporter": ["text-summary", "text", "html", "json"],
5+
"lines": 86,
6+
"statements": 85.93,
7+
"functions": 82.43,
8+
"branches": 76.06,
9+
"exclude": [
10+
"coverage",
11+
"test"
12+
]
13+
}

__tests__/src/AXObjectElementMap-test.js

Lines changed: 142 additions & 128 deletions
Large diffs are not rendered by default.

__tests__/src/AXObjectRoleMap-test.js

Lines changed: 148 additions & 133 deletions
Large diffs are not rendered by default.

__tests__/src/AXObjectsMap-test.js

Lines changed: 325 additions & 310 deletions
Large diffs are not rendered by default.

__tests__/src/elementAXObjectMap-test.js

Lines changed: 157 additions & 140 deletions
Large diffs are not rendered by default.
Lines changed: 32 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,45 @@
1-
/* eslint-env mocha */
2-
import expect from 'expect';
1+
import test from 'tape';
2+
import values from 'object.values';
3+
import mockProperty from 'mock-property';
4+
35
import iterationDecorator from '../../../src/util/iterationDecorator';
46

5-
describe('iterationDecorator', function () {
6-
describe('should add a Symbol.iterator property to a collection', function () {
7-
it('should return the values when iterated', function () {
7+
test('iterationDecorator', (t) => {
8+
t.test('adds a Symbol.iterator property to a collection', async (st) => {
89
// const collection = {a: 'apple', b: 'banana', c: 'cantaloupe'};
910
const collection = {
1011
'a': 'apple',
1112
'b': 'banana',
1213
'c': 'cantaloupe',
1314
};
1415
const arr = ['apple', 'banana', 'cantaloupe'];
15-
const iter = iterationDecorator(collection, Object.values(collection));
16-
expect([...iter]).toEqual(expect.arrayContaining(arr));
17-
});
16+
const iter = iterationDecorator(collection, values(collection));
17+
st.deepEqual([...iter], arr, 'returns the values when iterated');
1818
});
19-
describe('when Symbol is not defined in the global space', function () {
20-
beforeEach(function () {
21-
global.originalSymbol = global.Symbol
22-
global.originalSymbolIterator = global.Symbol.iterator;
23-
global.Symbol = undefined;
24-
});
25-
it('should not add a Symbol.iterator property to a collection', function () {
26-
const collection = {
27-
'a': 'apple',
28-
'b': 'banana',
29-
'c': 'cantaloupe',
30-
};
31-
const iter = iterationDecorator(collection, []);
32-
expect(iter[global.originalSymbolIterator]).not.toBeDefined();
33-
});
34-
afterEach(function () {
35-
global.Symbol = global.originalSymbol;
36-
global.originalSymbol = undefined;
37-
global.originalSymbolIterator = undefined;
38-
});
19+
20+
t.test('when Symbol is not defined in the global space', async (st) => {
21+
const originalSymbolIterator = typeof Symbol === 'function' ? Symbol.iterator : null;
22+
st.teardown(mockProperty(global, 'Symbol', { value: undefined }));
23+
24+
const collection = {
25+
'a': 'apple',
26+
'b': 'banana',
27+
'c': 'cantaloupe',
28+
};
29+
const iter = iterationDecorator(collection, []);
30+
st.equal(iter[originalSymbolIterator], undefined, 'does not add a Symbol.iterator property to a collection');
3931
});
40-
describe('when Symbol.iterator is not defined in the global space', function () {
41-
beforeEach(function () {
42-
global.originalSymbol = global.Symbol
43-
global.originalSymbolIterator = global.Symbol.iterator;
44-
global.Symbol = function () {};
45-
});
46-
it('should not add a Symbol.iterator property to a collection', function () {
47-
const collection = {
48-
'a': 'apple',
49-
'b': 'banana',
50-
'c': 'cantaloupe',
51-
};
52-
const iter = iterationDecorator(collection, []);
53-
expect(iter[global.originalSymbolIterator]).not.toBeDefined();
54-
});
55-
afterEach(function () {
56-
global.Symbol = global.originalSymbol;
57-
global.originalSymbol = undefined;
58-
global.originalSymbolIterator = undefined;
59-
});
32+
33+
t.test('when Symbol.iterator is not defined in the global space', async (st) => {
34+
const originalSymbolIterator = typeof Symbol === 'function' ? Symbol.iterator : null;
35+
st.teardown(mockProperty(global, 'Symbol', { value: function () {} }));
36+
37+
const collection = {
38+
'a': 'apple',
39+
'b': 'banana',
40+
'c': 'cantaloupe',
41+
};
42+
const iter = iterationDecorator(collection, []);
43+
st.equal(iter[originalSymbolIterator], undefined, 'does not add a Symbol.iterator property to a collection');
6044
});
6145
});
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
/* eslint-env mocha */
2-
import expect from 'expect';
1+
import test from 'tape';
2+
33
import iteratorProxy from '../../../src/util/iteratorProxy';
44

5-
describe('iteratorProxy', function () {
6-
it('should create an iterator for the bound array', function () {
7-
const arr = ['a', 'b', 'c'];
8-
const iter = {
9-
[Symbol.iterator]: iteratorProxy.bind(arr)
10-
};
11-
expect([...iter]).toEqual(expect.arrayContaining(arr));
12-
});
5+
test('iteratorProxy', async (t) => {
6+
const arr = ['a', 'b', 'c'];
7+
const iter = {
8+
[Symbol.iterator]: iteratorProxy.bind(arr)
9+
};
10+
11+
t.deepEqual([...iter], arr, 'creates an iterator for the bound array');
1312
});

0 commit comments

Comments
 (0)