forked from thinkb4/a-walk-in-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iterableAndIterators.test.js
51 lines (34 loc) · 1.54 KB
/
iterableAndIterators.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
describe('DAY 5: Iterable/Iterator', () => {
it(`get the iterator function of a String`, () => {
let string = 'hello';
let theIteratorFunction;
expect(theIteratorFunction).toBeInstanceOf(Object);
expect(theIteratorFunction).toBeInstanceOf(Function);
});
it(`get the iterator object returned by the iterator function of a String`, () => {
let string = 'hello';
let theIteratorObject;
expect(theIteratorObject).toBeInstanceOf(Object);
});
it(`get the string representation
of the iterator object returned by the iterator function of a String`, () => {
let string = 'hello';
let theIteratorObjectCoercedToString;
expect(theIteratorObjectCoercedToString).toBe('[object String Iterator]');
});
it(`get the next method returned by the iterator function of a String`, () => {
let string = 'hello';
let theIteratorNextMethod;
expect(theIteratorNextMethod).toBeInstanceOf(Object);
expect(theIteratorNextMethod).toBeInstanceOf(Function);
});
it(`get at least 1 value returned by the next method returned by the iterator function of a String`, () => {
let string = 'hello';
let theIteratorNextMethodValue;
expect(theIteratorNextMethodValue).toBe('h');
});
it(`make your own test to get all values from a String using the iterable protocol`, () => {
// I'm throwing and error to make it fail, remove it and add your code
throw Error('do not cheat 3:) ');
});
});