|
1 |
| -import { UIRouter } from "../src/router"; |
2 |
| -import { UrlService } from "../src/url/urlService"; |
| 1 | +import { stripLastPathElement } from '../src/common'; |
| 2 | +import { UIRouter } from '../src/router'; |
| 3 | +import { UrlService } from '../src/url/urlService'; |
3 | 4 | import * as vanilla from "../src/vanilla";
|
4 |
| -import { UrlMatcherFactory } from "../src/url/urlMatcherFactory"; |
| 5 | +import { UrlMatcherFactory } from '../src/url/urlMatcherFactory'; |
5 | 6 | import { BrowserLocationConfig } from '../src/vanilla';
|
6 | 7 | import { resetBrowserUrl } from './_testUtils';
|
7 | 8 |
|
8 | 9 | describe('BrowserLocationConfig implementation', () => {
|
9 |
| - afterAll(() => resetBrowserUrl()) |
| 10 | + afterAll(() => resetBrowserUrl()); |
10 | 11 |
|
11 | 12 | let router: UIRouter;
|
12 | 13 | let $url: UrlService;
|
@@ -62,14 +63,14 @@ describe('BrowserLocationConfig implementation', () => {
|
62 | 63 | expect(router.urlService.config.html5Mode()).toBe(true);
|
63 | 64 | let stub = spyOn(service._history, 'pushState');
|
64 | 65 | router.urlRouter.push($umf.compile('/hello/:name'), { name: 'world' }, {});
|
65 |
| - expect(stub.calls.first().args[2]).toBe('/hello/world'); |
| 66 | + expect(stub.calls.first().args[2]).toBe(stripLastPathElement($url.config.baseHref()) + '/hello/world'); |
66 | 67 | });
|
67 | 68 |
|
68 | 69 | it('uses history.replaceState when setting a url with replace', () => {
|
69 | 70 | let service = mockPushState(router);
|
70 | 71 | let stub = spyOn(service._history, 'replaceState');
|
71 | 72 | router.urlRouter.push($umf.compile('/hello/:name'), { name: 'world' }, { replace: true });
|
72 |
| - expect(stub.calls.first().args[2]).toBe('/hello/world'); |
| 73 | + expect(stub.calls.first().args[2]).toBe(stripLastPathElement($url.config.baseHref()) + '/hello/world'); |
73 | 74 | });
|
74 | 75 |
|
75 | 76 | it('returns the correct url query', async(done) => {
|
@@ -127,9 +128,9 @@ describe('BrowserLocationConfig implementation', () => {
|
127 | 128 | expect(blc.baseHref()).toBe('/base');
|
128 | 129 | });
|
129 | 130 |
|
130 |
| - it('uses location.href if <base> is not present', () => { |
| 131 | + it('uses location.pathname if <base> is not present', () => { |
131 | 132 | const blc = new BrowserLocationConfig();
|
132 |
| - expect(blc.baseHref()).toBe(location.href); |
| 133 | + expect(blc.baseHref()).toBe(location.pathname); |
133 | 134 | });
|
134 | 135 | });
|
135 | 136 |
|
|
0 commit comments