@@ -2,18 +2,22 @@ var expect = require('expect');
2
2
var HashLocation = require ( '../HashLocation' ) ;
3
3
4
4
describe ( 'HashLocation.getCurrentPath' , function ( ) {
5
+ afterEach ( function ( ) {
6
+ window . location . hash = '' ;
7
+ } ) ;
5
8
6
9
//this test is needed because Firefox will pre-decode the value retrieved from
7
10
//window.location.hash
8
- it ( 'returns a properly decoded equivalent of what window.location.hash is set to ' , function ( ) {
11
+ it ( 'returns a properly decoded equivalent of window.location.hash' , function ( ) {
9
12
window . location . hash = '' ;
10
13
expect ( HashLocation . getCurrentPath ( ) ) . toBe ( '' ) ;
11
14
12
15
window . location . hash = 'asdf' ;
13
16
expect ( HashLocation . getCurrentPath ( ) ) . toBe ( 'asdf' ) ;
14
17
18
+ // + is only special in the query component, not the hash
15
19
window . location . hash = 'test+spaces' ;
16
- expect ( HashLocation . getCurrentPath ( ) ) . toBe ( 'test spaces' ) ;
20
+ expect ( HashLocation . getCurrentPath ( ) ) . toBe ( 'test+ spaces' ) ;
17
21
18
22
window . location . hash = 'first%2Fsecond' ;
19
23
expect ( HashLocation . getCurrentPath ( ) ) . toBe ( 'first%2Fsecond' ) ;
@@ -24,7 +28,7 @@ describe('HashLocation.getCurrentPath', function () {
24
28
window . location . hash = 'first%252Fsecond' ;
25
29
expect ( HashLocation . getCurrentPath ( ) ) . toBe ( 'first%2Fsecond' ) ;
26
30
27
- //decodeURI doesn't handle lone percents
31
+ // decodeURI doesn't handle lone percents
28
32
window . location . hash = '%' ;
29
33
expect ( function ( ) {
30
34
HashLocation . getCurrentPath ( ) ;
@@ -36,10 +40,6 @@ describe('HashLocation.getCurrentPath', function () {
36
40
window . location . hash =
37
41
'complicated+string/full%2Fof%3Fspecial%25chars%2520and%23escapes%E1%88%B4' ;
38
42
expect ( HashLocation . getCurrentPath ( ) )
39
- . toBe ( 'complicated string/full%2Fof%3Fspecial%chars%20and%23escapesሴ' ) ;
40
- } ) ;
41
-
42
- afterEach ( function ( ) {
43
- window . location . hash = '' ;
43
+ . toBe ( 'complicated+string/full%2Fof%3Fspecial%chars%20and%23escapesሴ' ) ;
44
44
} ) ;
45
45
} ) ;
0 commit comments