@@ -162,66 +162,71 @@ describe('TabBar', () => {
162
162
tabbar . tabs . forEach ( ( tab ) => expect ( tab . relatedPanel . customTabTemplate ) . toBeDefined ( ) ) ;
163
163
} ) ;
164
164
165
- it ( 'should navigate to the correct URL when clicking on tab buttons' , fakeAsync ( ( ) => {
166
- const router = TestBed . get ( Router ) ;
167
- const location = TestBed . get ( Location ) ;
168
- const fixture = TestBed . createComponent ( TabBarRoutingTestComponent ) ;
169
- const bottomNav = fixture . componentInstance . bottomNavComp ;
170
- fixture . detectChanges ( ) ;
171
-
172
- fixture . ngZone . run ( ( ) => { router . initialNavigation ( ) ; } ) ;
173
- tick ( ) ;
174
- expect ( location . path ( ) ) . toBe ( '/' ) ;
175
-
176
- const theTabs = bottomNav . contentTabs . toArray ( ) ;
177
-
178
- fixture . ngZone . run ( ( ) => { theTabs [ 2 ] . elementRef ( ) . nativeElement . dispatchEvent ( new Event ( 'click' ) ) ; } ) ;
179
- tick ( ) ;
180
- expect ( location . path ( ) ) . toBe ( '/view3' ) ;
181
-
182
- fixture . ngZone . run ( ( ) => { theTabs [ 1 ] . elementRef ( ) . nativeElement . dispatchEvent ( new Event ( 'click' ) ) ; } ) ;
183
- tick ( ) ;
184
- expect ( location . path ( ) ) . toBe ( '/view2' ) ;
185
-
186
- fixture . ngZone . run ( ( ) => { theTabs [ 0 ] . elementRef ( ) . nativeElement . dispatchEvent ( new Event ( 'click' ) ) ; } ) ;
187
- tick ( ) ;
188
- expect ( location . path ( ) ) . toBe ( '/view1' ) ;
189
- } ) ) ;
190
-
191
- it ( 'should select the correct tab button/panel when navigating an URL' , fakeAsync ( ( ) => {
192
- const router = TestBed . get ( Router ) ;
193
- const location = TestBed . get ( Location ) ;
194
- const fixture = TestBed . createComponent ( TabBarRoutingTestComponent ) ;
195
- const bottomNav = fixture . componentInstance . bottomNavComp ;
196
- fixture . detectChanges ( ) ;
165
+ describe ( 'Routing Navigation Tests' , ( ) => {
166
+ configureTestSuite ( ) ;
167
+
168
+ let router ;
169
+ let location ;
170
+ let fixture ;
171
+ let bottomNav ;
172
+ let theTabs ;
173
+
174
+ beforeEach ( async ( ( ) => {
175
+ router = TestBed . get ( Router ) ;
176
+ location = TestBed . get ( Location ) ;
177
+ fixture = TestBed . createComponent ( TabBarRoutingTestComponent ) ;
178
+ bottomNav = fixture . componentInstance . bottomNavComp ;
179
+ fixture . detectChanges ( ) ;
180
+ theTabs = bottomNav . contentTabs . toArray ( ) ;
181
+ } ) ) ;
182
+
183
+ it ( 'should navigate to the correct URL when clicking on tab buttons' , fakeAsync ( ( ) => {
184
+ fixture . ngZone . run ( ( ) => { router . initialNavigation ( ) ; } ) ;
185
+ tick ( ) ;
186
+ expect ( location . path ( ) ) . toBe ( '/' ) ;
187
+
188
+ fixture . ngZone . run ( ( ) => { theTabs [ 2 ] . elementRef ( ) . nativeElement . dispatchEvent ( new Event ( 'click' ) ) ; } ) ;
189
+ tick ( ) ;
190
+ expect ( location . path ( ) ) . toBe ( '/view3' ) ;
191
+
192
+ fixture . ngZone . run ( ( ) => { theTabs [ 1 ] . elementRef ( ) . nativeElement . dispatchEvent ( new Event ( 'click' ) ) ; } ) ;
193
+ tick ( ) ;
194
+ expect ( location . path ( ) ) . toBe ( '/view2' ) ;
195
+
196
+ fixture . ngZone . run ( ( ) => { theTabs [ 0 ] . elementRef ( ) . nativeElement . dispatchEvent ( new Event ( 'click' ) ) ; } ) ;
197
+ tick ( ) ;
198
+ expect ( location . path ( ) ) . toBe ( '/view1' ) ;
199
+ } ) ) ;
200
+
201
+ it ( 'should select the correct tab button/panel when navigating an URL' , fakeAsync ( ( ) => {
202
+ fixture . ngZone . run ( ( ) => { router . initialNavigation ( ) ; } ) ;
203
+ tick ( ) ;
204
+ expect ( location . path ( ) ) . toBe ( '/' ) ;
205
+
206
+ fixture . ngZone . run ( ( ) => { router . navigate ( [ '/view3' ] ) ; } ) ;
207
+ tick ( ) ;
208
+ expect ( location . path ( ) ) . toBe ( '/view3' ) ;
209
+ fixture . detectChanges ( ) ;
210
+ expect ( bottomNav . selectedIndex ) . toBe ( 2 ) ;
211
+ expect ( theTabs [ 2 ] . isSelected ) . toBe ( true ) ;
212
+
213
+ fixture . ngZone . run ( ( ) => { router . navigate ( [ '/view2' ] ) ; } ) ;
214
+ tick ( ) ;
215
+ expect ( location . path ( ) ) . toBe ( '/view2' ) ;
216
+ fixture . detectChanges ( ) ;
217
+ expect ( bottomNav . selectedIndex ) . toBe ( 1 ) ;
218
+ expect ( theTabs [ 1 ] . isSelected ) . toBe ( true ) ;
219
+
220
+ fixture . ngZone . run ( ( ) => { router . navigate ( [ '/view1' ] ) ; } ) ;
221
+ tick ( ) ;
222
+ expect ( location . path ( ) ) . toBe ( '/view1' ) ;
223
+ fixture . detectChanges ( ) ;
224
+ expect ( bottomNav . selectedIndex ) . toBe ( 0 ) ;
225
+ expect ( theTabs [ 0 ] . isSelected ) . toBe ( true ) ;
226
+ } ) ) ;
197
227
198
- fixture . ngZone . run ( ( ) => { router . initialNavigation ( ) ; } ) ;
199
- tick ( ) ;
200
- expect ( location . path ( ) ) . toBe ( '/' ) ;
201
-
202
- const theTabs = bottomNav . contentTabs . toArray ( ) ;
203
-
204
- fixture . ngZone . run ( ( ) => { router . navigate ( [ '/view3' ] ) ; } ) ;
205
- tick ( ) ;
206
- expect ( location . path ( ) ) . toBe ( '/view3' ) ;
207
- fixture . detectChanges ( ) ;
208
- expect ( bottomNav . selectedIndex ) . toBe ( 2 ) ;
209
- expect ( theTabs [ 2 ] . isSelected ) . toBe ( true ) ;
210
-
211
- fixture . ngZone . run ( ( ) => { router . navigate ( [ '/view2' ] ) ; } ) ;
212
- tick ( ) ;
213
- expect ( location . path ( ) ) . toBe ( '/view2' ) ;
214
- fixture . detectChanges ( ) ;
215
- expect ( bottomNav . selectedIndex ) . toBe ( 1 ) ;
216
- expect ( theTabs [ 1 ] . isSelected ) . toBe ( true ) ;
228
+ } ) ;
217
229
218
- fixture . ngZone . run ( ( ) => { router . navigate ( [ '/view1' ] ) ; } ) ;
219
- tick ( ) ;
220
- expect ( location . path ( ) ) . toBe ( '/view1' ) ;
221
- fixture . detectChanges ( ) ;
222
- expect ( bottomNav . selectedIndex ) . toBe ( 0 ) ;
223
- expect ( theTabs [ 0 ] . isSelected ) . toBe ( true ) ;
224
- } ) ) ;
225
230
} ) ;
226
231
227
232
@Component ( {
0 commit comments