11import { List , Map } from 'immutable' ;
22import { expect } from 'chai' ;
33
4- import { setEntries , next , vote } from '../src/core' ;
4+ import { setEntries , next , vote , restart } from '../src/core' ;
55
66describe ( 'application logic' , ( ) => {
77
@@ -12,7 +12,8 @@ describe('application logic', () => {
1212 const entries = List . of ( 'Trainspotting' , '28 Days Later' ) ;
1313 const nextState = setEntries ( state , entries ) ;
1414 expect ( nextState ) . to . equal ( Map ( {
15- entries : List . of ( 'Trainspotting' , '28 Days Later' )
15+ entries : List . of ( 'Trainspotting' , '28 Days Later' ) ,
16+ initialEntries : List . of ( 'Trainspotting' , '28 Days Later' )
1617 } ) ) ;
1718 } ) ;
1819
@@ -21,7 +22,8 @@ describe('application logic', () => {
2122 const entries = [ 'Trainspotting' , '28 Days Later' ] ;
2223 const nextState = setEntries ( state , entries ) ;
2324 expect ( nextState ) . to . equal ( Map ( {
24- entries : List . of ( 'Trainspotting' , '28 Days Later' )
25+ entries : List . of ( 'Trainspotting' , '28 Days Later' ) ,
26+ initialEntries : List . of ( 'Trainspotting' , '28 Days Later' )
2527 } ) ) ;
2628 } ) ;
2729
@@ -113,6 +115,32 @@ describe('application logic', () => {
113115
114116 } ) ;
115117
118+ describe ( 'restart' , ( ) => {
119+
120+ it ( 'returns to initial entries and takes the first two entries under vote' , ( ) => {
121+ expect (
122+ restart ( Map ( {
123+ vote : Map ( {
124+ round : 1 ,
125+ pair : List . of ( 'Trainspotting' , 'Sunshine' )
126+ } ) ,
127+ entries : List ( ) ,
128+ initialEntries : List . of ( 'Trainspotting' , '28 Days Later' , 'Sunshine' )
129+ } ) )
130+ ) . to . equal (
131+ Map ( {
132+ vote : Map ( {
133+ round : 2 ,
134+ pair : List . of ( 'Trainspotting' , '28 Days Later' )
135+ } ) ,
136+ entries : List . of ( 'Sunshine' ) ,
137+ initialEntries : List . of ( 'Trainspotting' , '28 Days Later' , 'Sunshine' )
138+ } )
139+ ) ;
140+ } ) ;
141+
142+ } ) ;
143+
116144 describe ( 'vote' , ( ) => {
117145
118146 it ( 'creates a tally for the voted entry' , ( ) => {
0 commit comments