Skip to content

Commit e2f7c0d

Browse files
committedDec 28, 2020
[Tests] re-enable eslint in the tests
1 parent f8cd8f5 commit e2f7c0d

File tree

2 files changed

+54
-43
lines changed

2 files changed

+54
-43
lines changed
 

‎.eslintrc

+12-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"CreateIterResultObject",
1616
"GetIntrinsic",
1717
"GetIterator",
18+
"HasOwnProperty",
1819
"OrdinaryObjectCreate",
1920
"OrdinarySetPrototypeOf",
2021
"IsArray",
@@ -24,8 +25,8 @@
2425
"SameValue",
2526
"SameValueZero",
2627
"ToString",
27-
"Type"
28-
]
28+
"Type",
29+
],
2930
}],
3031
"no-magic-numbers": [2, {
3132
"ignore": [0, 1, 2]
@@ -37,8 +38,15 @@
3738
{
3839
"files": "**/*.mjs",
3940
"rules": {
40-
"no-restricted-exports": 0
41-
}
41+
"no-restricted-exports": 0,
42+
},
43+
},
44+
{
45+
"files": "test/**/*",
46+
"rules": {
47+
"max-lines-per-function": 0,
48+
"no-magic-numbers": 0,
49+
},
4250
}
4351
]
4452
}

‎test/tests.js

+42-39
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ var define = require('define-properties');
77
var hasSymbols = require('has-symbols')();
88
var ArrayFrom = require('array.from').implementation;
99

10-
/* eslint-disable */
11-
12-
var testMapping = function (t, map, key, value, desc) {
13-
if (!desc) desc = "";
14-
t.equal(map.has(key), false, desc + " - .has(key) returns false");
15-
t.equal(map.get(key), undefined, desc + " - .get(key) returns undefined");
16-
t.equal(map.set(key, value), map, desc + " - .set(key) returns the map");
17-
t.equal(map.get(key), value, desc + " - .get(key) returns the value");
18-
t.equal(map.has(key), true, desc + " - .has(key) returns true");
10+
// eslint-disable-next-line max-params
11+
var testMapping = function testMapping(t, map, key, value, desc) {
12+
if (!desc) { desc = ''; } // eslint-disable-line no-param-reassign
13+
t.equal(map.has(key), false, desc + ' - .has(key) returns false');
14+
t.equal(map.get(key), undefined, desc + ' - .get(key) returns undefined');
15+
t.equal(map.set(key, value), map, desc + ' - .set(key) returns the map');
16+
t.equal(map.get(key), value, desc + ' - .get(key) returns the value');
17+
t.equal(map.has(key), true, desc + ' - .has(key) returns true');
1918
};
2019

2120
var entriesArray = function (map) {
@@ -43,22 +42,22 @@ var expectNotEnumerable = function (t, object, desc) {
4342
}
4443
};
4544

46-
module.exports = function (Map, t) {
45+
module.exports = function runTests(Map, t) {
4746
t.test('should has valid getter and setter calls', function (st) {
4847
var map = new Map();
4948

50-
st.doesNotThrow(function () { map.get({}) });
51-
st.doesNotThrow(function () { map.set({}) });
52-
st.doesNotThrow(function () { map.has({}) });
53-
st.doesNotThrow(function () { map["delete"]({}) });
49+
st.doesNotThrow(function () { map.get({}); });
50+
st.doesNotThrow(function () { map.set({}); });
51+
st.doesNotThrow(function () { map.has({}); });
52+
st.doesNotThrow(function () { map['delete']({}); });
5453

5554
st.end();
5655
});
5756

58-
t.test('throws when `.call`ed with an existing instance', function (t) {
57+
t.test('throws when `.call`ed with an existing instance', function (st) {
5958
var map = new Map();
60-
t.throws(function () { Map.call(map); }, 'Map can not be .called on an existing map');
61-
t.end();
59+
st['throws'](function () { Map.call(map); }, 'Map can not be .called on an existing map');
60+
st.end();
6261
});
6362

6463
t.test('should accept an iterable as argument', function (st) {
@@ -78,16 +77,16 @@ module.exports = function (Map, t) {
7877
});
7978

8079
t.test('should throw with iterables that return primitives', function (st) {
81-
st.throws(function () { return new Map('123'); }, TypeError, 'string');
82-
st.throws(function () { return new Map([1, 2, 3]); }, TypeError, 'array of numbers');
83-
st.throws(function () { return new Map(['1', '2', '3']); }, TypeError, 'array of strings');
84-
st.throws(function () { return new Map([true]); }, TypeError, 'array of booleans');
80+
st['throws'](function () { return new Map('123'); }, TypeError, 'string');
81+
st['throws'](function () { return new Map([1, 2, 3]); }, TypeError, 'array of numbers');
82+
st['throws'](function () { return new Map(['1', '2', '3']); }, TypeError, 'array of strings');
83+
st['throws'](function () { return new Map([true]); }, TypeError, 'array of booleans');
8584

8685
st.end();
8786
});
8887

8988
t.test('should not be callable without "new"', function (st) {
90-
st.throws(Map, TypeError, 'call without new');
89+
st['throws'](Map, TypeError, 'call without new');
9190

9291
st.end();
9392
});
@@ -188,11 +187,11 @@ module.exports = function (Map, t) {
188187
var map = new Map();
189188

190189
testMapping(st, map, {}, true, 'test {} key');
191-
testMapping(st, map, null, true,'test null key' );
192-
testMapping(st, map, undefined, true,'test undefined key' );
190+
testMapping(st, map, null, true, 'test null key');
191+
testMapping(st, map, undefined, true, 'test undefined key');
193192
testMapping(st, map, '', true, 'test "" key');
194-
testMapping(st, map, NaN, true,'test NaN key' );
195-
testMapping(st, map, 0, true,'test 0 key' );
193+
testMapping(st, map, NaN, true, 'test NaN key');
194+
testMapping(st, map, 0, true, 'test 0 key');
196195

197196
st.end();
198197
});
@@ -351,8 +350,8 @@ module.exports = function (Map, t) {
351350
t.test('#size', { skip: !define.supportsDescriptors }, function (st) {
352351
st.test('throws TypeError when accessed directly', function (sst) {
353352
// see https://github.com/paulmillr/es6-shim/issues/176
354-
sst.throws(function () { return Map.prototype.size; }, TypeError, 'Map.prototype.set throws (1)');
355-
sst.throws(function () { return Map.prototype.size; }, TypeError, 'Map.prototype.set throws (2)');
353+
sst['throws'](function () { return Map.prototype.size; }, TypeError, 'Map.prototype.set throws (1)');
354+
sst['throws'](function () { return Map.prototype.size; }, TypeError, 'Map.prototype.set throws (2)');
356355

357356
sst.end();
358357
});
@@ -636,12 +635,14 @@ module.exports = function (Map, t) {
636635
st.end();
637636
});
638637

639-
// Disabled since we don't have Set here
640-
// t.test('MapIterator identification test prototype inequality', { skip: !Object.getPrototypeOf }, function (st) {
641-
// var mapEntriesProto = Object.getPrototypeOf(new Map().entries());
642-
// var setEntriesProto = Object.getPrototypeOf(new Set().entries());
643-
// st.notEqual(mapEntriesProto, setEntriesProto);
644-
// });
638+
/*
639+
* Disabled since we don't have Set here
640+
* t.test('MapIterator identification test prototype inequality', { skip: !Object.getPrototypeOf }, function (st) {
641+
* var mapEntriesProto = Object.getPrototypeOf(new Map().entries());
642+
* var setEntriesProto = Object.getPrototypeOf(new Set().entries());
643+
* st.notEqual(mapEntriesProto, setEntriesProto);
644+
* });
645+
*/
645646

646647
t.test('MapIterator identification', function (st) {
647648
var fnMapValues = Map.prototype.values;
@@ -650,11 +651,13 @@ module.exports = function (Map, t) {
650651
var testMapValues = testMap.values();
651652
st.equal(testMapValues.next.call(fnMapValues.call(mapSentinel)).value, 'MapSentinel', 'extracts value from a different map');
652653

653-
// var testSet = new Set();
654-
// var testSetValues = testSet.values();
655-
// st.throws(function () {
656-
// return testSetValues.next.call(fnMapValues.call(mapSentinel)).value;
657-
// }, TypeError);
654+
/*
655+
* var testSet = new Set();
656+
* var testSetValues = testSet.values();
657+
* st.throws(function () {
658+
* return testSetValues.next.call(fnMapValues.call(mapSentinel)).value;
659+
* }, TypeError);
660+
*/
658661

659662
st.end();
660663
});

0 commit comments

Comments
 (0)
Please sign in to comment.