-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
esnext.set.find.js
27 lines (22 loc) · 1007 Bytes
/
esnext.set.find.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import Set from 'core-js-pure/features/set';
QUnit.test('Set#find', assert => {
const { find } = Set.prototype;
assert.isFunction(find);
assert.arity(find, 1);
assert.name(find, 'find');
assert.nonEnumerable(Set.prototype, 'find');
const set = new Set([1]);
const context = {};
set.find(function (value, key, that) {
assert.same(arguments.length, 3, 'correct number of callback arguments');
assert.same(value, 1, 'correct value in callback');
assert.same(key, 1, 'correct key in callback');
assert.same(that, set, 'correct link to set in callback');
assert.same(this, context, 'correct callback context');
}, context);
assert.same(new Set([2, 3, 4]).find(it => it % 2), 3);
assert.same(new Set().find(it => it === 42), undefined);
assert.throws(() => find.call({}, () => { /* empty */ }), TypeError);
assert.throws(() => find.call(undefined, () => { /* empty */ }), TypeError);
assert.throws(() => find.call(null, () => { /* empty */ }), TypeError);
});