@@ -33,29 +33,34 @@ describe('pushStateLocationService', () => {
33
33
expect ( router . urlService . config . html5Mode ( ) ) . toBe ( true ) ;
34
34
} ) ;
35
35
36
- it ( 'returns the correct path' , async ( done ) => {
37
- await $state . go ( 'path' , { urlParam : 'bar' } ) ;
38
-
36
+ it ( 'sets and returns the correct path' , ( ) => {
37
+ $url . url ( '/path/bar' ) ;
39
38
expect ( window . location . pathname ) . toBe ( '/path/bar' ) ;
40
39
expect ( $url . path ( ) ) . toBe ( '/path/bar' ) ;
41
40
expect ( $url . search ( ) ) . toEqual ( { } ) ;
41
+ } ) ;
42
42
43
- done ( ) ;
43
+ it ( 'sets and returns an empty path' , ( ) => {
44
+ $url . url ( '' ) ;
45
+ expect ( window . location . pathname ) . toBe ( '' ) ;
46
+ expect ( $url . path ( ) ) . toBe ( '' ) ;
44
47
} ) ;
45
48
46
- it ( 'returns the correct search' , async ( done ) => {
47
- await $state . go ( 'path' , { urlParam : 'bar' , queryParam : 'query' } ) ;
49
+ it ( 'sets and returns a path with a single slash' , ( ) => {
50
+ $url . url ( '/' ) ;
51
+ expect ( window . location . pathname ) . toBe ( '/' ) ;
52
+ expect ( $url . path ( ) ) . toBe ( '/' ) ;
53
+ } ) ;
48
54
55
+ it ( 'returns the correct search' , ( ) => {
56
+ $url . url ( '/path/bar?queryParam=query' ) ;
49
57
expect ( window . location . pathname ) . toBe ( '/path/bar' ) ;
50
58
expect ( window . location . search ) . toBe ( '?queryParam=query' ) ;
51
59
expect ( $url . path ( ) ) . toBe ( '/path/bar' ) ;
52
60
expect ( $url . search ( ) ) . toEqual ( { queryParam : 'query' } ) ;
53
-
54
- done ( ) ;
55
61
} ) ;
56
62
57
-
58
- describe ( 'with base tag' , ( ) => {
63
+ fdescribe ( 'with base tag' , ( ) => {
59
64
let baseTag : HTMLBaseElement ;
60
65
const applyBaseTag = ( href : string ) => {
61
66
baseTag = document . createElement ( 'base' ) ;
@@ -72,71 +77,183 @@ describe('pushStateLocationService', () => {
72
77
expect ( router . urlService . config . html5Mode ( ) ) . toBe ( true ) ;
73
78
} ) ;
74
79
75
- it ( 'returns the correct url' , async ( done ) => {
76
- await $state . go ( 'path' , { urlParam : 'bar' } ) ;
80
+ it ( 'handles bar correctly' , ( ) => {
81
+ $url . url ( 'bar' ) ;
82
+ expect ( window . location . pathname ) . toBe ( '/base/bar' ) ;
83
+ expect ( $url . path ( ) ) . toBe ( '/bar' ) ;
84
+ } ) ;
85
+
86
+ it ( 'handles /bar correctly' , ( ) => {
87
+ $url . url ( '/bar' ) ;
88
+ expect ( window . location . pathname ) . toBe ( '/base/bar' ) ;
89
+ expect ( $url . path ( ) ) . toBe ( '/bar' ) ;
90
+ } ) ;
77
91
92
+ it ( 'handles /path/bar correctly' , ( ) => {
93
+ $url . url ( '/path/bar' ) ;
78
94
expect ( window . location . pathname ) . toBe ( '/base/path/bar' ) ;
79
95
expect ( $url . path ( ) ) . toBe ( '/path/bar' ) ;
80
- expect ( $url . search ( ) ) . toEqual ( { } ) ;
96
+ } ) ;
81
97
82
- done ( ) ;
98
+ it ( 'handles / correctly' , ( ) => {
99
+ $url . url ( '/' ) ;
100
+ expect ( window . location . pathname ) . toBe ( '/base/' ) ;
101
+ expect ( $url . path ( ) ) . toBe ( '/' ) ;
83
102
} ) ;
84
103
85
- it ( 'returns the correct search' , async ( done ) => {
86
- await $state . go ( 'path' , { urlParam : 'bar' , queryParam : 'query' } ) ;
104
+ it ( 'handles "" correctly' , ( ) => {
105
+ $url . url ( 'foobar' ) ;
106
+ expect ( window . location . pathname ) . toBe ( '/base/foobar' ) ;
107
+ $url . url ( '' ) ;
108
+ expect ( window . location . pathname ) . toBe ( '/base/' ) ;
109
+ expect ( $url . path ( ) ) . toBe ( '/' ) ;
110
+ } ) ;
87
111
112
+ it ( 'handles ?queryParam=query correctly' , ( ) => {
113
+ $url . url ( '/path/bar?queryParam=query' ) ;
88
114
expect ( window . location . pathname ) . toBe ( '/base/path/bar' ) ;
89
115
expect ( window . location . search ) . toBe ( '?queryParam=query' ) ;
90
116
expect ( $url . path ( ) ) . toBe ( '/path/bar' ) ;
91
117
expect ( $url . search ( ) ) . toEqual ( { queryParam : 'query' } ) ;
92
-
93
- done ( ) ;
94
118
} ) ;
95
119
} ) ;
96
120
97
121
describe ( '/debug.html' , ( ) => {
98
122
beforeEach ( ( ) => applyBaseTag ( "/debug.html" ) ) ;
99
123
100
- it ( 'returns the correct url' , async ( done ) => {
101
- await $state . go ( 'path' , { urlParam : 'bar' } ) ;
124
+ it ( 'handles bar correctly' , ( ) => {
125
+ $url . url ( 'bar' ) ;
126
+ expect ( window . location . pathname ) . toBe ( '/bar' ) ;
127
+ expect ( $url . path ( ) ) . toBe ( '/bar' ) ;
128
+ } ) ;
129
+
130
+ it ( 'handles /bar correctly' , ( ) => {
131
+ $url . url ( '/bar' ) ;
132
+ expect ( window . location . pathname ) . toBe ( '/bar' ) ;
133
+ expect ( $url . path ( ) ) . toBe ( '/bar' ) ;
134
+ } ) ;
102
135
136
+ it ( 'handles /path/bar correctly' , ( ) => {
137
+ $url . url ( '/path/bar' ) ;
103
138
expect ( window . location . pathname ) . toBe ( '/path/bar' ) ;
104
139
expect ( $url . path ( ) ) . toBe ( '/path/bar' ) ;
140
+ } ) ;
141
+
142
+ it ( 'handles / correctly' , ( ) => {
143
+ $url . url ( '/' ) ;
144
+ expect ( window . location . pathname ) . toBe ( '/debug.html' ) ;
145
+ expect ( $url . path ( ) ) . toBe ( '/' ) ;
146
+ } ) ;
147
+
148
+ it ( 'handles "" correctly' , ( ) => {
149
+ $url . url ( 'foobar' ) ;
150
+ expect ( window . location . pathname ) . toBe ( '/foobar' ) ;
151
+ $url . url ( '' ) ;
152
+ expect ( window . location . pathname ) . toBe ( '/debug.html' ) ;
153
+ expect ( $url . path ( ) ) . toBe ( '/' ) ;
154
+ } ) ;
105
155
106
- done ( ) ;
156
+ it ( 'handles ?queryParam=query correctly' , ( ) => {
157
+ $url . url ( '/path/bar?queryParam=query' ) ;
158
+ expect ( window . location . pathname ) . toBe ( '/path/bar' ) ;
159
+ expect ( window . location . search ) . toBe ( '?queryParam=query' ) ;
160
+ expect ( $url . path ( ) ) . toBe ( '/path/bar' ) ;
161
+ expect ( $url . search ( ) ) . toEqual ( { queryParam : 'query' } ) ;
107
162
} ) ;
108
163
} ) ;
109
164
110
165
describe ( origin + '/debug.html' , ( ) => {
111
166
beforeEach ( ( ) => applyBaseTag ( origin + '/debug.html' ) ) ;
112
167
113
- it ( 'returns the correct url' , async ( done ) => {
114
- await $state . go ( 'path' , { urlParam : 'bar' } ) ;
168
+ it ( 'handles bar correctly' , ( ) => {
169
+ $url . url ( 'bar' ) ;
170
+ expect ( window . location . pathname ) . toBe ( '/bar' ) ;
171
+ expect ( $url . path ( ) ) . toBe ( '/bar' ) ;
172
+ } ) ;
115
173
174
+ it ( 'handles /bar correctly' , ( ) => {
175
+ $url . url ( '/bar' ) ;
176
+ expect ( window . location . pathname ) . toBe ( '/bar' ) ;
177
+ expect ( $url . path ( ) ) . toBe ( '/bar' ) ;
178
+ } ) ;
179
+
180
+ it ( 'handles /path/bar correctly' , ( ) => {
181
+ $url . url ( '/path/bar' ) ;
116
182
expect ( window . location . pathname ) . toBe ( '/path/bar' ) ;
117
183
expect ( $url . path ( ) ) . toBe ( '/path/bar' ) ;
184
+ } ) ;
185
+
186
+ it ( 'handles / correctly' , ( ) => {
187
+ $url . url ( '/' ) ;
188
+ expect ( window . location . pathname ) . toBe ( '/debug.html' ) ;
189
+ expect ( $url . path ( ) ) . toBe ( '/' ) ;
190
+ } ) ;
191
+
192
+ it ( 'handles "" correctly' , ( ) => {
193
+ $url . url ( 'foobar' ) ;
194
+ expect ( window . location . pathname ) . toBe ( '/foobar' ) ;
195
+ $url . url ( '' ) ;
196
+ expect ( window . location . pathname ) . toBe ( '/debug.html' ) ;
197
+ expect ( $url . path ( ) ) . toBe ( '/' ) ;
198
+ } ) ;
118
199
119
- done ( ) ;
200
+ it ( 'handles ?queryParam=query correctly' , ( ) => {
201
+ $url . url ( '/path/bar?queryParam=query' ) ;
202
+ expect ( window . location . pathname ) . toBe ( '/path/bar' ) ;
203
+ expect ( window . location . search ) . toBe ( '?queryParam=query' ) ;
204
+ expect ( $url . path ( ) ) . toBe ( '/path/bar' ) ;
205
+ expect ( $url . search ( ) ) . toEqual ( { queryParam : 'query' } ) ;
120
206
} ) ;
121
207
} ) ;
122
208
123
209
describe ( origin + '/base/debug.html' , ( ) => {
124
210
beforeEach ( ( ) => applyBaseTag ( origin + '/base/debug.html' ) ) ;
125
211
126
- it ( 'returns the correct url' , async ( done ) => {
127
- await $state . go ( 'path' , { urlParam : 'bar' } ) ;
212
+ it ( 'handles bar correctly' , ( ) => {
213
+ $url . url ( 'bar' ) ;
214
+ expect ( window . location . pathname ) . toBe ( '/base/bar' ) ;
215
+ expect ( $url . path ( ) ) . toBe ( '/bar' ) ;
216
+ } ) ;
128
217
218
+ it ( 'handles /bar correctly' , ( ) => {
219
+ $url . url ( '/bar' ) ;
220
+ expect ( window . location . pathname ) . toBe ( '/base/bar' ) ;
221
+ expect ( $url . path ( ) ) . toBe ( '/bar' ) ;
222
+ } ) ;
223
+
224
+ it ( 'handles /path/bar correctly' , ( ) => {
225
+ $url . url ( '/path/bar' ) ;
129
226
expect ( window . location . pathname ) . toBe ( '/base/path/bar' ) ;
130
227
expect ( $url . path ( ) ) . toBe ( '/path/bar' ) ;
228
+ } ) ;
131
229
132
- done ( ) ;
230
+ it ( 'handles / correctly' , ( ) => {
231
+ $url . url ( '/' ) ;
232
+ expect ( window . location . pathname ) . toBe ( '/base/' ) ;
233
+ expect ( $url . path ( ) ) . toBe ( '/' ) ;
234
+ } ) ;
235
+
236
+ it ( 'handles "" correctly' , ( ) => {
237
+ $url . url ( 'foobar' ) ;
238
+ expect ( window . location . pathname ) . toBe ( '/base/foobar' ) ;
239
+ $url . url ( '' ) ;
240
+ expect ( window . location . pathname ) . toBe ( '/base/debug.html' ) ;
241
+ expect ( $url . path ( ) ) . toBe ( '/' ) ;
242
+ } ) ;
243
+
244
+ it ( 'handles ?queryParam=query correctly' , ( ) => {
245
+ $url . url ( '/path/bar?queryParam=query' ) ;
246
+ expect ( window . location . pathname ) . toBe ( '/base/path/bar' ) ;
247
+ expect ( window . location . search ) . toBe ( '?queryParam=query' ) ;
248
+ expect ( $url . path ( ) ) . toBe ( '/path/bar' ) ;
249
+ expect ( $url . search ( ) ) . toEqual ( { queryParam : 'query' } ) ;
133
250
} ) ;
134
251
} ) ;
135
252
136
253
describe ( 'window.location.pathname exactly' , ( ) => {
137
254
beforeEach ( ( ) => applyBaseTag ( window . location . pathname ) ) ;
138
255
139
- it ( 'returns the correct url' , ( ) => {
256
+ it ( 'returns the correct url, / ' , ( ) => {
140
257
expect ( $url . path ( ) ) . toBe ( '/' ) ;
141
258
} ) ;
142
259
} ) ;
0 commit comments