-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathes.iterator.find.js
31 lines (26 loc) · 1.22 KB
/
es.iterator.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
28
29
30
31
import { createIterator } from '../helpers/helpers.js';
import { STRICT, STRICT_THIS } from '../helpers/constants.js';
QUnit.test('Iterator#find', assert => {
const { find } = Iterator.prototype;
assert.isFunction(find);
assert.arity(find, 1);
assert.name(find, 'find');
assert.looksNative(find);
assert.nonEnumerable(Iterator.prototype, 'find');
assert.same(find.call(createIterator([1, 2, 3]), it => !(it % 2)), 2, 'basic functionality');
find.call(createIterator([1]), function (arg, counter) {
assert.same(this, STRICT_THIS, 'this');
assert.same(arguments.length, 2, 'arguments length');
assert.same(arg, 1, 'argument');
assert.same(counter, 0, 'counter');
});
if (STRICT) {
assert.throws(() => find.call(undefined, () => { /* empty */ }), TypeError);
assert.throws(() => find.call(null, () => { /* empty */ }), TypeError);
}
assert.throws(() => find.call({}, () => { /* empty */ }), TypeError);
assert.throws(() => find.call([], () => { /* empty */ }), TypeError);
assert.throws(() => find.call(createIterator([1]), undefined), TypeError);
assert.throws(() => find.call(createIterator([1]), null), TypeError);
assert.throws(() => find.call(createIterator([1]), {}), TypeError);
});