1+ import {
2+ SettingsScreen ,
3+ Tab1Screen ,
4+ } from '../../../bluebase/expo/apps/plugin-settings-app/Screens' ;
5+ import { BlueBase } from '@bluebase/core' ;
6+ import Plugin from '../../index' ;
7+ import { createNavigator } from '../createNavigator' ;
8+
9+ const inputRoutes = {
10+ initialRouteName : 'Home' ,
11+ routes : [
12+ {
13+ exact : true ,
14+ name : 'Settings' ,
15+ navigationOptions : { } ,
16+ path : '/p/settings' ,
17+ screen : SettingsScreen ,
18+ } ,
19+ ] ,
20+ type : 'stack' ,
21+ } ;
22+
23+ describe ( 'createNavigator tests' , ( ) => {
24+ it ( 'should test if there is no navigator in routes' , async ( ) => {
25+ const BB = new BlueBase ( ) ;
26+ await BB . Plugins . register ( Plugin ) ;
27+ createNavigator ( inputRoutes , { } as any , BB ) ;
28+ expect ( createNavigator ) . toBeTruthy ( ) ;
29+ } ) ;
30+ it ( 'should test if there is no navigator in routes' , async ( ) => {
31+ const BB = new BlueBase ( ) ;
32+ await BB . Plugins . register ( Plugin ) ;
33+
34+ inputRoutes . routes . push ( {
35+ name : 'Settings' ,
36+ path : '/p/settings' ,
37+ screen : SettingsScreen ,
38+ } as any ) ;
39+
40+ createNavigator ( inputRoutes , { } as any , BB ) ;
41+ expect ( createNavigator ) . toBeTruthy ( ) ;
42+ } ) ;
43+
44+ it ( 'should test if there is navigator an screen in routes' , ( ) => {
45+ inputRoutes . routes . push ( {
46+ name : 'SettingsTabs' ,
47+ screen : SettingsScreen ,
48+ navigator : {
49+ routes : [ {
50+ name : 'Tab1' ,
51+ navigationOptions : {
52+ title : 'Tab A' ,
53+ } ,
54+ path : 't1' ,
55+ screen : Tab1Screen ,
56+ } ] ,
57+ } ,
58+ path : 'tabs' ,
59+ } as any ) ;
60+ createNavigator ( inputRoutes , { } as any , { } as any ) ;
61+ expect ( createNavigator ) . toBeTruthy ( ) ;
62+ } ) ;
63+
64+ it ( 'should test if there is navigator only in routes' , ( ) => {
65+ inputRoutes . routes . push ( {
66+ name : 'SettingsTabs' ,
67+ navigator : {
68+ routes : [ {
69+ name : 'Tab1' ,
70+ navigationOptions : {
71+ title : 'Tab A' ,
72+ } ,
73+ path : 't1' ,
74+ screen : Tab1Screen ,
75+ } ] ,
76+ } ,
77+ path : 'tabs' ,
78+ } as any ) ;
79+ createNavigator ( inputRoutes , { } as any , { } as any ) ;
80+ expect ( createNavigator ) . toBeTruthy ( ) ;
81+ } ) ;
82+ it ( 'should test if there is only screen component in routes' , ( ) => {
83+ inputRoutes . routes . push ( {
84+ navigator : {
85+ routes : [ { screen : SettingsScreen } ]
86+ }
87+ } as any ) ;
88+ createNavigator ( inputRoutes , { } as any , { } as any ) ;
89+ expect ( createNavigator ) . toBeTruthy ( ) ;
90+ } ) ;
91+ } ) ;
0 commit comments