1
1
import { expect } from 'chai' ;
2
2
import { List , Map } from 'immutable' ;
3
3
4
- import { setEntries } from '../src/core' ;
4
+ import { setEntries , next } from '../src/core' ;
5
5
6
6
// describe application logic
7
7
describe ( 'Application Logic' , ( ) => {
8
- describe ( 'setEntries' , ( ) => {
9
- let state = null ;
8
+ let state = null ;
10
9
10
+ describe ( 'setEntries' , ( ) => {
11
11
beforeEach ( ( ) => {
12
12
// runs before each test in this block
13
13
state = new Map ( ) ;
@@ -32,4 +32,24 @@ describe('Application Logic', () => {
32
32
expect ( nextState . get ( 'entries' ) ) . to . equal ( List . of ( ...entries ) ) ;
33
33
} ) ;
34
34
} ) ;
35
+
36
+ describe ( 'next' , ( ) => {
37
+ beforeEach ( ( ) => {
38
+ state = new Map ( {
39
+ entries : List . of ( 'Kill Bill' , 'Pulp Fiction' , 'Reservoir Dogs' )
40
+ } ) ;
41
+ } ) ;
42
+
43
+ // the next vote reducer should take the next two entries
44
+ // in the state and put them under vote. it should also remove
45
+ // those voting entries from the 'entries' map in the state.
46
+ it ( 'takes the next two entries under vote' , ( ) => {
47
+ const nextState = next ( state ) ;
48
+
49
+ expect ( nextState ) . to . include . key ( 'vote' ) ;
50
+ expect ( nextState . get ( 'vote' ) ) . to . include . key ( 'pair' ) ;
51
+ expect ( nextState . get ( 'vote' ) . get ( 'pair' ) ) . to . have . sizeOf ( 2 ) ;
52
+ expect ( nextState . get ( 'vote' ) . get ( 'pair' ) ) . to . equal ( List . of ( 'Kill Bill' , 'Pulp Fiction' ) ) ;
53
+ } ) ;
54
+ } ) ;
35
55
} ) ;
0 commit comments