-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkata.js
41 lines (32 loc) · 983 Bytes
/
kata.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
32
33
34
35
36
37
38
39
40
41
// 50: Generator - iterator
// To do: make all tests pass, leave the assert lines unchanged!
describe('a generator returns an iterable object', function() {
function* generatorFunction(){
yield 1;
yield 2;
}
let generator;
beforeEach(() => {
generator = generatorFunction();
});
it('a generator returns an object', function() {
const typeOfTheGenerator = '';
assert.equal(typeof generator, typeOfTheGenerator);
});
it('a generator object has a key `Symbol.iterator`', function() {
const key = '???';
assert.equal(key in generator, true);
});
it('the `Symbol.iterator` is a function', function() {
const theType = typeof generator.Symbol.iterator;
assert.equal(theType, 'function');
});
it('can be looped with `for-of`, which expects an iterable', function() {
function iterateForOf(){
for (let value of {}) {
// no statements needed
}
}
assert.doesNotThrow(iterateForOf);
});
});