1
- import { UrlMatcher } from "../src/index" ;
2
1
import { UIRouter } from "../src/router" ;
3
2
import { UrlService } from "../src/url/urlService" ;
4
3
import * as vanilla from "../src/vanilla" ;
5
4
import { UrlMatcherFactory } from "../src/url/urlMatcherFactory" ;
5
+ import { BrowserLocationConfig } from '../src/vanilla' ;
6
6
7
7
describe ( 'browserHistory implementation' , ( ) => {
8
8
@@ -18,22 +18,22 @@ describe('browserHistory implementation', () => {
18
18
19
19
mockHistory = {
20
20
replaceState : ( a , b , url ) => mockLocation . href = url ,
21
- pushState : ( a , b , url ) => mockLocation . href = url
21
+ pushState : ( a , b , url ) => mockLocation . href = url ,
22
22
} ;
23
23
24
24
mockLocation = {
25
25
_href : "/" ,
26
26
pathname : "/" ,
27
27
search : "" ,
28
28
get href ( ) {
29
- return this . _href
29
+ return this . _href ;
30
30
} ,
31
31
set href ( val ) {
32
32
this . _href = val ;
33
- var [ pathname , search ] = val . split ( "?" ) ;
33
+ let [ pathname , search ] = val . split ( "?" ) ;
34
34
this . pathname = pathname ;
35
35
this . search = search ? "?" + search : "" ;
36
- }
36
+ } ,
37
37
} ;
38
38
39
39
plugin . service . _history = mockHistory ;
@@ -51,7 +51,7 @@ describe('browserHistory implementation', () => {
51
51
52
52
router . stateRegistry . register ( {
53
53
url : '/path/:urlParam?queryParam' ,
54
- name : 'path'
54
+ name : 'path' ,
55
55
} ) ;
56
56
} ) ;
57
57
@@ -71,7 +71,8 @@ describe('browserHistory implementation', () => {
71
71
} ) ;
72
72
73
73
it ( 'returns the correct url query' , async ( done ) => {
74
- let service = mockPushState ( router ) ;
74
+ mockPushState ( router ) ;
75
+
75
76
expect ( router . urlService . config . html5Mode ( ) ) . toBe ( true ) ;
76
77
77
78
await router . stateService . go ( 'path' , { urlParam : 'bar' } ) ;
@@ -89,8 +90,16 @@ describe('browserHistory implementation', () => {
89
90
90
91
expect ( $url . path ( ) ) . toBe ( '/path/bar' ) ;
91
92
expect ( $url . search ( ) ) . toEqual ( { queryParam : 'query' } ) ;
93
+ expect ( $url . search ( ) ) . toEqual ( { queryParam : 'query' } ) ;
92
94
93
95
done ( ) ;
94
96
} ) ;
95
97
96
- } ) ;
98
+ it ( 'returns URL portions from the location object' , ( ) => {
99
+ const blc = new BrowserLocationConfig ( ) ;
100
+
101
+ expect ( blc . host ( ) ) . toBe ( location . hostname ) ;
102
+ expect ( blc . port ( ) ) . toBe ( parseInt ( location . port , 10 ) ) ;
103
+ expect ( blc . protocol ( ) + ":" ) . toBe ( location . protocol ) ;
104
+ } ) ;
105
+ } ) ;
0 commit comments