@@ -5,30 +5,32 @@ import React from 'react-native';
55import Scene from '../src/Scene' ;
66import createReducer from '../src/Reducer' ;
77
8- const scenesData = < Scene component = "Modal" key = "modal" >
9- < Scene key = "launch" component = "Launch" />
10- < Scene key = "sideMenu" component = "Drawer" initial = { true } >
11- < Scene component = "CubeBar" key = "cubeBar" type = "tabs" >
12- < Scene key = "main" tabs = { true } >
13- < Scene key = "home" component = "Home" />
14- < Scene key = "map" component = "Map" />
15- < Scene key = "myAccount" component = "MyAccount" />
16- </ Scene >
17- < Scene key = "messaging" initial = { true } >
18- < Scene key = "conversations" component = "Conversations" />
19- </ Scene >
20- </ Scene >
21- </ Scene >
22- < Scene key = "privacyPolicy" component = "PrivacyPolicy" type = "modal" />
23- < Scene key = "termsOfService" component = "TermsOfService" type = "modal" />
24- < Scene key = "login" >
25- < Scene key = "loginModal1" component = "Login1" />
26- < Scene key = "loginModal2" component = "Login2" />
27- </ Scene >
28- </ Scene > ;
29-
308describe ( 'Actions' , ( ) => {
319 it ( 'should create needed actions' , ( ) => {
10+ let id = 0 ;
11+ const guid = ( ) => id ++ ;
12+
13+ const scenesData = < Scene component = "Modal" key = "modal" getInitialState = { ( ) => ( { foo : guid ( ) } ) } >
14+ < Scene key = "launch" component = "Launch" />
15+ < Scene key = "sideMenu" component = "Drawer" initial = { true } >
16+ < Scene component = "CubeBar" key = "cubeBar" type = "tabs" >
17+ < Scene key = "main" tabs = { true } >
18+ < Scene key = "home" component = "Home" />
19+ < Scene key = "map" component = "Map" />
20+ < Scene key = "myAccount" component = "MyAccount" />
21+ </ Scene >
22+ < Scene key = "messaging" initial = { true } >
23+ < Scene key = "conversations" component = "Conversations" getInitialState = { ( ) => ( { foo : 'what' , bar : guid ( ) } ) } />
24+ </ Scene >
25+ </ Scene >
26+ </ Scene >
27+ < Scene key = "privacyPolicy" component = "PrivacyPolicy" type = "modal" />
28+ < Scene key = "termsOfService" component = "TermsOfService" type = "modal" />
29+ < Scene key = "login" >
30+ < Scene key = "loginModal1" component = "Login1" />
31+ < Scene key = "loginModal2" component = "Login2" />
32+ </ Scene >
33+ </ Scene > ;
3234 const scenes = Actions . create ( scenesData ) ;
3335 expect ( scenes . conversations . component ) . to . equal ( "Conversations" ) ;
3436
@@ -57,6 +59,8 @@ describe('Actions', () => {
5759 expect ( state ) . equal ( undefined ) ;
5860 Actions . init ( ) ;
5961 expect ( state . key ) . equal ( "0_modal" ) ;
62+ expect ( state . children [ 0 ] . children [ 0 ] . children [ 0 ] . children [ 0 ] . bar ) . equal ( 1 ) ;
63+ expect ( state . children [ 0 ] . children [ 0 ] . children [ 0 ] . children [ 0 ] . foo ) . equal ( 'what' ) ;
6064
6165 Actions . messaging ( ) ;
6266 expect ( currentScene . key ) . equal ( "messaging" ) ;
@@ -69,6 +73,9 @@ describe('Actions', () => {
6973 Actions . pop ( ) ;
7074 expect ( state . from . key ) . equal ( "1_login" ) ;
7175
76+ Actions . launch ( ) ;
77+ expect ( state . children [ 1 ] . foo ) . equal ( 3 ) ;
78+ expect ( state . children [ 1 ] . bar ) . equal ( undefined ) ;
7279 } ) ;
7380
7481} ) ;
0 commit comments