forked from thinkb4/a-walk-in-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerators.test.js
30 lines (21 loc) · 938 Bytes
/
generators.test.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
describe('DAY 7: generators', () => {
it(`complete the function code to pass the test`, () => {
var msg = [`don't`, `repeat`, `yourself`];
/**
* Modify the function to return a Generator object
* complete the body of the generator using a for...of statement
* iterate over the iterable input and yeild the valuefor...of loop
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of
*
* @param {array} input
* @returns {Generator}
*/
function gen () {
}
let myGen = gen(msg);
expect(myGen.next()).toEqual({ value: `don't`, done: false });
expect(myGen.next()).toEqual({ value: `repeat`, done: false });
expect(myGen.next()).toEqual({ value: `yourself`, done: false });
expect(myGen.next()).toEqual({ value: undefined, done: true });
});
});