@@ -97,6 +97,29 @@ describe(RouterHistoryStore.name, () => {
9797 } ;
9898 }
9999
100+ it ( 'the URLs behave like the History API when navigating using links' , async ( ) => {
101+ const { click, routerHistory } = await setup ( ) ;
102+ let currentUrl : string | undefined ;
103+ routerHistory . currentUrl$ . subscribe ( ( url ) => {
104+ currentUrl = url ;
105+ } ) ;
106+ let previousUrl : string | null | undefined ;
107+ routerHistory . previousUrl$ . subscribe ( ( url ) => {
108+ previousUrl = url ;
109+ } ) ;
110+
111+ // At Home
112+ await click ( '#about-link' ) ;
113+ // At About
114+ await click ( '#company-link' ) ;
115+ // At Company
116+ await click ( '#products-link' ) ;
117+ // At Products
118+
119+ expect ( currentUrl ) . toBe ( '/products' ) ;
120+ expect ( previousUrl ) . toBe ( '/company' ) ;
121+ } ) ;
122+
100123 it ( 'the URLs behave like the History API when navigating back' , async ( ) => {
101124 const { click, routerHistory } = await setup ( ) ;
102125 let currentUrl : string | undefined ;
@@ -119,4 +142,29 @@ describe(RouterHistoryStore.name, () => {
119142 expect ( currentUrl ) . toBe ( '/about' ) ;
120143 expect ( previousUrl ) . toBe ( '/home' ) ;
121144 } ) ;
145+
146+ it ( 'the URLs behave like the History API when navigating back then using links' , async ( ) => {
147+ const { click, routerHistory } = await setup ( ) ;
148+ let currentUrl : string | undefined ;
149+ routerHistory . currentUrl$ . subscribe ( ( url ) => {
150+ currentUrl = url ;
151+ } ) ;
152+ let previousUrl : string | null | undefined ;
153+ routerHistory . previousUrl$ . subscribe ( ( url ) => {
154+ previousUrl = url ;
155+ } ) ;
156+
157+ // At Home
158+ await click ( '#about-link' ) ;
159+ // At About
160+ await click ( '#company-link' ) ;
161+ // At Company
162+ await click ( '#back-link' ) ;
163+ // At About
164+ await click ( '#products-link' ) ;
165+ // At Products
166+
167+ expect ( currentUrl ) . toBe ( '/products' ) ;
168+ expect ( previousUrl ) . toBe ( '/about' ) ;
169+ } ) ;
122170} ) ;
0 commit comments