Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit b28784d

Browse files
committed
test($location): tests for no base tag
1 parent b16d825 commit b28784d

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

Diff for: test/ng/locationSpec.js

+40-3
Original file line numberDiff line numberDiff line change
@@ -875,10 +875,19 @@ describe('$location', function() {
875875
});
876876
}
877877

878-
function initBrowser() {
878+
function initBrowser(atRoot, noBase) {
879879
return function($browser){
880-
$browser.url('http://host.com/base');
881-
$browser.$$baseHref = '/base/index.html';
880+
if (atRoot) {
881+
$browser.url('http://host.com/');
882+
if (!noBase) {
883+
$browser.$$baseHref = '/';
884+
}
885+
} else {
886+
$browser.url('http://host.com/base');
887+
if (!noBase) {
888+
$browser.$$baseHref = '/base/index.html';
889+
}
890+
}
882891
};
883892
}
884893

@@ -1234,6 +1243,34 @@ describe('$location', function() {
12341243
});
12351244

12361245

1246+
it('should replace path while on root when relative link begins with "/" and history enabled on old browser', function() {
1247+
configureService('/link', true, false, true);
1248+
inject(
1249+
initBrowser(true),
1250+
initLocation(),
1251+
function($browser, $location) {
1252+
$location.path('/some');
1253+
browserTrigger(link, 'click');
1254+
expectRewriteTo($browser, 'http://host.com/#!/link');
1255+
}
1256+
);
1257+
});
1258+
1259+
1260+
it('should not rewrite when relative link begins with "/" and there is no base tag and history enabled on old browser', function() {
1261+
configureService('/link', true, false, true);
1262+
inject(
1263+
initBrowser(false, true),
1264+
initLocation(),
1265+
function($browser, $location) {
1266+
$location.path('/some');
1267+
browserTrigger(link, 'click');
1268+
expectNoRewrite($browser);
1269+
}
1270+
);
1271+
});
1272+
1273+
12371274
it('should not rewrite when relative link begins with "/" and history enabled on old browser', function() {
12381275
configureService('/other_base/link', true, false, true);
12391276
inject(

0 commit comments

Comments
 (0)