@@ -97,7 +97,34 @@ describe(RouterHistoryStore.name, () => {
97
97
} ;
98
98
}
99
99
100
+ it ( 'the URLs behave like the History API when navigating using links' , async ( ) => {
101
+ expect . assertions ( 2 ) ;
102
+
103
+ const { click, routerHistory } = await setup ( ) ;
104
+ let currentUrl : string | undefined ;
105
+ routerHistory . currentUrl$ . subscribe ( ( url ) => {
106
+ currentUrl = url ;
107
+ } ) ;
108
+ let previousUrl : string | null | undefined ;
109
+ routerHistory . previousUrl$ . subscribe ( ( url ) => {
110
+ previousUrl = url ;
111
+ } ) ;
112
+
113
+ // At Home
114
+ await click ( '#about-link' ) ;
115
+ // At About
116
+ await click ( '#company-link' ) ;
117
+ // At Company
118
+ await click ( '#products-link' ) ;
119
+ // At Products
120
+
121
+ expect ( currentUrl ) . toBe ( '/products' ) ;
122
+ expect ( previousUrl ) . toBe ( '/company' ) ;
123
+ } ) ;
124
+
100
125
it ( 'the URLs behave like the History API when navigating back' , async ( ) => {
126
+ expect . assertions ( 2 ) ;
127
+
101
128
const { click, routerHistory } = await setup ( ) ;
102
129
let currentUrl : string | undefined ;
103
130
routerHistory . currentUrl$ . subscribe ( ( url ) => {
@@ -119,4 +146,31 @@ describe(RouterHistoryStore.name, () => {
119
146
expect ( currentUrl ) . toBe ( '/about' ) ;
120
147
expect ( previousUrl ) . toBe ( '/home' ) ;
121
148
} ) ;
149
+
150
+ it ( 'the URLs behave like the History API when navigating back then using links' , async ( ) => {
151
+ expect . assertions ( 2 ) ;
152
+
153
+ const { click, routerHistory } = await setup ( ) ;
154
+ let currentUrl : string | undefined ;
155
+ routerHistory . currentUrl$ . subscribe ( ( url ) => {
156
+ currentUrl = url ;
157
+ } ) ;
158
+ let previousUrl : string | null | undefined ;
159
+ routerHistory . previousUrl$ . subscribe ( ( url ) => {
160
+ previousUrl = url ;
161
+ } ) ;
162
+
163
+ // At Home
164
+ await click ( '#about-link' ) ;
165
+ // At About
166
+ await click ( '#company-link' ) ;
167
+ // At Company
168
+ await click ( '#back-link' ) ;
169
+ // At About
170
+ await click ( '#products-link' ) ;
171
+ // At Products
172
+
173
+ expect ( currentUrl ) . toBe ( '/products' ) ;
174
+ expect ( previousUrl ) . toBe ( '/about' ) ;
175
+ } ) ;
122
176
} ) ;
0 commit comments