File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -146,6 +146,28 @@ describe('cy/navigation', () => {
146146 expect ( triggeredHashChange ) . to . be . false
147147 } )
148148
149+ it ( 'when no urls or urlPosition in state' , ( ) => {
150+ const state = $SetterGetter . create ( {
151+ navHistoryDelta : 1 ,
152+ } )
153+
154+ const triggeredHashChange = historyNavigationTriggeredHashChange ( state )
155+
156+ expect ( triggeredHashChange ) . to . be . false
157+ } )
158+
159+ it ( 'when no urlPosition in state' , ( ) => {
160+ const state = $SetterGetter . create ( {
161+ navHistoryDelta : 1 ,
162+ url : 'https://my_url.com/' ,
163+ urls : [ 'https://my_url.com/' , 'https://my_url.com/home' ] ,
164+ } )
165+
166+ const triggeredHashChange = historyNavigationTriggeredHashChange ( state )
167+
168+ expect ( triggeredHashChange ) . to . be . false
169+ } )
170+
149171 it ( 'when neither url has a hash' , ( ) => {
150172 const state = $SetterGetter . create ( {
151173 navHistoryDelta : 1 ,
Original file line number Diff line number Diff line change 1+ import _ from 'lodash'
12import { $Location } from '../cypress/location'
23
34export const bothUrlsMatchAndOneHasHash = ( current , remote , eitherShouldHaveHash : boolean = false ) : boolean => {
@@ -26,6 +27,11 @@ export const historyNavigationTriggeredHashChange = (state): boolean => {
2627
2728 const urls = state ( 'urls' )
2829 const urlPosition = state ( 'urlPosition' )
30+
31+ if ( _ . isEmpty ( urls ) || urlPosition === undefined ) {
32+ return false
33+ }
34+
2935 const currentUrl = $Location . create ( urls [ urlPosition ] )
3036
3137 const nextPosition = urlPosition + delta
You can’t perform that action at this time.
0 commit comments