@@ -10,6 +10,8 @@ const CounterView = props=> (
1010 < span className = "count" > { props . count } </ span >
1111 < span className = "wrapperProps" > { props . wrapperProps } </ span >
1212 < span className = "overwritedProps" > { props . overwritedProps } </ span >
13+ < span className = "backward" onClick = { props . history . backward } > -</ span >
14+ < span className = "forward" onClick = { props . history . forward } > +</ span >
1315 </ div >
1416)
1517
@@ -50,11 +52,12 @@ describe('react-most', () => {
5052 let counter = TestUtils . findRenderedComponentWithType ( counterWrapper , Counter )
5153
5254 do$ ( [ ( ) => counter . actions . inc ( ) ,
53- ( ) => counter . actions . inc ( ) ] )
55+ ( ) => counter . actions . fromPromise ( Promise . resolve ( { type :'inc' } ) ) ,
56+ ( ) => counter . actions . fromEvent ( { type :'inc' } ) ] )
5457
5558 return historyStreamOf ( counter )
56- . take$ ( 2 )
57- . then ( state => expect ( state . count ) . toEqual ( 2 ) )
59+ . take$ ( 3 )
60+ . then ( state => expect ( state . count ) . toEqual ( 3 ) )
5861 } )
5962
6063 it ( 'sink can also generate intent' , ( ) => {
@@ -134,4 +137,41 @@ describe('react-most', () => {
134137 } )
135138 } )
136139 } ) ;
140+
141+ describe ( 'history' , ( ) => {
142+ it ( 'can undo' , ( ) => {
143+ let counterWrapper = TestUtils . renderIntoDocument (
144+ < Most >
145+ < Counter history = { true } />
146+ </ Most >
147+ )
148+ let counter = TestUtils . findRenderedComponentWithType ( counterWrapper , Counter )
149+ return do$ ( [
150+ ( ) => counter . actions . inc ( ) ,
151+ ( ) => counter . actions . inc ( ) ,
152+ ( ) => counter . actions . inc ( )
153+ ] ) . then ( ( ) => {
154+ let backward = TestUtils . findRenderedDOMComponentWithClass ( counterWrapper , 'backward' )
155+ TestUtils . Simulate . click ( backward )
156+ TestUtils . Simulate . click ( backward )
157+ TestUtils . Simulate . click ( backward )
158+ } ) . then ( ( ) => {
159+ let count = TestUtils . findRenderedDOMComponentWithClass ( counterWrapper , 'count' )
160+ expect ( count . textContent ) . toBe ( '1' )
161+ } ) . then ( ( ) => {
162+ let forward = TestUtils . findRenderedDOMComponentWithClass ( counterWrapper , 'forward' )
163+ TestUtils . Simulate . click ( forward )
164+ } ) . then ( ( ) => {
165+ let count = TestUtils . findRenderedDOMComponentWithClass ( counterWrapper , 'count' )
166+ expect ( count . textContent ) . toBe ( '2' )
167+ } ) . then ( ( ) => {
168+ let forward = TestUtils . findRenderedDOMComponentWithClass ( counterWrapper , 'forward' )
169+ TestUtils . Simulate . click ( forward )
170+ TestUtils . Simulate . click ( forward )
171+ } ) . then ( ( ) => {
172+ let count = TestUtils . findRenderedDOMComponentWithClass ( counterWrapper , 'count' )
173+ expect ( count . textContent ) . toBe ( '3' )
174+ } )
175+ } )
176+ } )
137177} )
0 commit comments