@@ -40,15 +40,17 @@ describe('pushStateLocationService', () => {
40
40
expect ( $url . search ( ) ) . toEqual ( { } ) ;
41
41
} ) ;
42
42
43
- it ( 'sets and returns an empty path' , ( ) => {
43
+ it ( 'returns a slash when an empty path is set' , ( ) => {
44
+ const base = $url . config . baseHref ( ) ;
44
45
$url . url ( '' ) ;
45
- expect ( window . location . pathname ) . toBe ( '' ) ;
46
- expect ( $url . path ( ) ) . toBe ( '' ) ;
46
+ expect ( window . location . pathname ) . toBe ( base ) ;
47
+ expect ( $url . path ( ) ) . toBe ( '/ ' ) ;
47
48
} ) ;
48
49
49
50
it ( 'sets and returns a path with a single slash' , ( ) => {
51
+ const base = $url . config . baseHref ( ) ;
50
52
$url . url ( '/' ) ;
51
- expect ( window . location . pathname ) . toBe ( '/' ) ;
53
+ expect ( window . location . pathname ) . toBe ( base ) ;
52
54
expect ( $url . path ( ) ) . toBe ( '/' ) ;
53
55
} ) ;
54
56
@@ -60,7 +62,7 @@ describe('pushStateLocationService', () => {
60
62
expect ( $url . search ( ) ) . toEqual ( { queryParam : 'query' } ) ;
61
63
} ) ;
62
64
63
- fdescribe ( 'with base tag' , ( ) => {
65
+ describe ( 'with base tag' , ( ) => {
64
66
let baseTag : HTMLBaseElement ;
65
67
const applyBaseTag = ( href : string ) => {
66
68
baseTag = document . createElement ( 'base' ) ;
@@ -71,55 +73,57 @@ describe('pushStateLocationService', () => {
71
73
afterEach ( ( ) => baseTag . parentElement . removeChild ( baseTag ) ) ;
72
74
73
75
describe ( '/base/' , ( ) => {
74
- beforeEach ( ( ) => applyBaseTag ( "/base/" ) ) ;
76
+ const base = '/base/' ;
77
+ beforeEach ( ( ) => applyBaseTag ( base ) ) ;
75
78
76
79
it ( 'reports html5Mode to be true' , ( ) => {
77
80
expect ( router . urlService . config . html5Mode ( ) ) . toBe ( true ) ;
78
81
} ) ;
79
82
80
83
it ( 'handles bar correctly' , ( ) => {
81
84
$url . url ( 'bar' ) ;
82
- expect ( window . location . pathname ) . toBe ( '/ base/ bar' ) ;
85
+ expect ( window . location . pathname ) . toBe ( ` ${ base } bar` ) ;
83
86
expect ( $url . path ( ) ) . toBe ( '/bar' ) ;
84
87
} ) ;
85
88
86
89
it ( 'handles /bar correctly' , ( ) => {
87
90
$url . url ( '/bar' ) ;
88
- expect ( window . location . pathname ) . toBe ( '/ base/ bar' ) ;
91
+ expect ( window . location . pathname ) . toBe ( ` ${ base } bar` ) ;
89
92
expect ( $url . path ( ) ) . toBe ( '/bar' ) ;
90
93
} ) ;
91
94
92
95
it ( 'handles /path/bar correctly' , ( ) => {
93
96
$url . url ( '/path/bar' ) ;
94
- expect ( window . location . pathname ) . toBe ( '/ base/ path/bar' ) ;
97
+ expect ( window . location . pathname ) . toBe ( ` ${ base } path/bar` ) ;
95
98
expect ( $url . path ( ) ) . toBe ( '/path/bar' ) ;
96
99
} ) ;
97
100
98
101
it ( 'handles / correctly' , ( ) => {
99
102
$url . url ( '/' ) ;
100
- expect ( window . location . pathname ) . toBe ( '/ base/' ) ;
103
+ expect ( window . location . pathname ) . toBe ( base ) ;
101
104
expect ( $url . path ( ) ) . toBe ( '/' ) ;
102
105
} ) ;
103
106
104
107
it ( 'handles "" correctly' , ( ) => {
105
108
$url . url ( 'foobar' ) ;
106
- expect ( window . location . pathname ) . toBe ( '/ base/ foobar' ) ;
109
+ expect ( window . location . pathname ) . toBe ( ` ${ base } foobar` ) ;
107
110
$url . url ( '' ) ;
108
- expect ( window . location . pathname ) . toBe ( '/ base/' ) ;
111
+ expect ( window . location . pathname ) . toBe ( base ) ;
109
112
expect ( $url . path ( ) ) . toBe ( '/' ) ;
110
113
} ) ;
111
114
112
115
it ( 'handles ?queryParam=query correctly' , ( ) => {
113
116
$url . url ( '/path/bar?queryParam=query' ) ;
114
- expect ( window . location . pathname ) . toBe ( '/ base/ path/bar' ) ;
117
+ expect ( window . location . pathname ) . toBe ( ` ${ base } path/bar` ) ;
115
118
expect ( window . location . search ) . toBe ( '?queryParam=query' ) ;
116
119
expect ( $url . path ( ) ) . toBe ( '/path/bar' ) ;
117
120
expect ( $url . search ( ) ) . toEqual ( { queryParam : 'query' } ) ;
118
121
} ) ;
119
122
} ) ;
120
123
121
124
describe ( '/debug.html' , ( ) => {
122
- beforeEach ( ( ) => applyBaseTag ( "/debug.html" ) ) ;
125
+ const base = "/debug.html" ;
126
+ beforeEach ( ( ) => applyBaseTag ( base ) ) ;
123
127
124
128
it ( 'handles bar correctly' , ( ) => {
125
129
$url . url ( 'bar' ) ;
@@ -141,15 +145,15 @@ describe('pushStateLocationService', () => {
141
145
142
146
it ( 'handles / correctly' , ( ) => {
143
147
$url . url ( '/' ) ;
144
- expect ( window . location . pathname ) . toBe ( '/debug.html' ) ;
148
+ expect ( window . location . pathname ) . toBe ( base ) ;
145
149
expect ( $url . path ( ) ) . toBe ( '/' ) ;
146
150
} ) ;
147
151
148
152
it ( 'handles "" correctly' , ( ) => {
149
153
$url . url ( 'foobar' ) ;
150
154
expect ( window . location . pathname ) . toBe ( '/foobar' ) ;
151
155
$url . url ( '' ) ;
152
- expect ( window . location . pathname ) . toBe ( '/debug.html' ) ;
156
+ expect ( window . location . pathname ) . toBe ( base ) ;
153
157
expect ( $url . path ( ) ) . toBe ( '/' ) ;
154
158
} ) ;
155
159
@@ -163,7 +167,8 @@ describe('pushStateLocationService', () => {
163
167
} ) ;
164
168
165
169
describe ( origin + '/debug.html' , ( ) => {
166
- beforeEach ( ( ) => applyBaseTag ( origin + '/debug.html' ) ) ;
170
+ const base = '/debug.html' ;
171
+ beforeEach ( ( ) => applyBaseTag ( origin + base ) ) ;
167
172
168
173
it ( 'handles bar correctly' , ( ) => {
169
174
$url . url ( 'bar' ) ;
@@ -185,15 +190,15 @@ describe('pushStateLocationService', () => {
185
190
186
191
it ( 'handles / correctly' , ( ) => {
187
192
$url . url ( '/' ) ;
188
- expect ( window . location . pathname ) . toBe ( '/debug.html' ) ;
193
+ expect ( window . location . pathname ) . toBe ( base ) ;
189
194
expect ( $url . path ( ) ) . toBe ( '/' ) ;
190
195
} ) ;
191
196
192
197
it ( 'handles "" correctly' , ( ) => {
193
198
$url . url ( 'foobar' ) ;
194
199
expect ( window . location . pathname ) . toBe ( '/foobar' ) ;
195
200
$url . url ( '' ) ;
196
- expect ( window . location . pathname ) . toBe ( '/debug.html' ) ;
201
+ expect ( window . location . pathname ) . toBe ( base ) ;
197
202
expect ( $url . path ( ) ) . toBe ( '/' ) ;
198
203
} ) ;
199
204
@@ -207,7 +212,8 @@ describe('pushStateLocationService', () => {
207
212
} ) ;
208
213
209
214
describe ( origin + '/base/debug.html' , ( ) => {
210
- beforeEach ( ( ) => applyBaseTag ( origin + '/base/debug.html' ) ) ;
215
+ const base = '/base/debug.html' ;
216
+ beforeEach ( ( ) => applyBaseTag ( origin + base ) ) ;
211
217
212
218
it ( 'handles bar correctly' , ( ) => {
213
219
$url . url ( 'bar' ) ;
@@ -229,15 +235,15 @@ describe('pushStateLocationService', () => {
229
235
230
236
it ( 'handles / correctly' , ( ) => {
231
237
$url . url ( '/' ) ;
232
- expect ( window . location . pathname ) . toBe ( '/ base/' ) ;
238
+ expect ( window . location . pathname ) . toBe ( base ) ;
233
239
expect ( $url . path ( ) ) . toBe ( '/' ) ;
234
240
} ) ;
235
241
236
242
it ( 'handles "" correctly' , ( ) => {
237
243
$url . url ( 'foobar' ) ;
238
244
expect ( window . location . pathname ) . toBe ( '/base/foobar' ) ;
239
245
$url . url ( '' ) ;
240
- expect ( window . location . pathname ) . toBe ( '/ base/debug.html' ) ;
246
+ expect ( window . location . pathname ) . toBe ( base ) ;
241
247
expect ( $url . path ( ) ) . toBe ( '/' ) ;
242
248
} ) ;
243
249
0 commit comments