generated from rollup/rollup-starter-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
61 lines (51 loc) · 1.62 KB
/
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
52
53
54
55
56
57
58
59
60
61
import test from 'ava';
import cartwheel from '.';
test('is a function', t => {
t.is(typeof cartwheel, 'function');
});
test('returns an iterator object', t => {
const iterator = cartwheel([42]);
t.is(typeof iterator.next, 'function');
t.is(typeof iterator.previous, 'function');
});
test('returns the first element on the first next()', t => {
const iterator = cartwheel([42, 16, 37]);
t.is(iterator.next().value, 42);
});
test('returns the last element on the first previous()', t => {
const iterator = cartwheel([42, 16, 37]);
t.is(iterator.previous().value, 37);
});
test('returns the next element on subsequent next()', t => {
const iterator = cartwheel([42, 16, 37]);
iterator.next();
t.is(iterator.next().value, 16);
});
test('returns the previous element on subsequent previous()', t => {
const iterator = cartwheel([42, 16, 37]);
iterator.next();
iterator.next();
t.is(iterator.previous().value, 42);
});
test('cycles back to the first element on next() from the last element', t => {
const iterator = cartwheel([42, 16, 37]);
iterator.next();
iterator.next();
iterator.next();
t.is(iterator.next().value, 42);
});
test('cycles back to the last element on previous() from the first element', t => {
const iterator = cartwheel([42, 16, 37]);
iterator.next();
t.is(iterator.previous().value, 37);
});
test('returns the next value on nextValue()', t => {
const iterator = cartwheel([42, 16, 37]);
iterator.next();
t.is(iterator.nextValue(), 16);
});
test('returns the previous value on previousValue()', t => {
const iterator = cartwheel([42, 16, 37]);
iterator.next();
t.is(iterator.previousValue(), 37);
});