Skip to content

Commit 92d2f0a

Browse files
committed
Fix location tests
1 parent 4d4905c commit 92d2f0a

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

src/core/location/location.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,12 +599,15 @@ export class LocationProvider {
599599
this.html5ModeConf.enabled = html5Mode.enabled;
600600
}
601601

602-
if (isDefined(html5Mode.enabled) && isBoolean(html5Mode.requireBase)) {
602+
if (
603+
isDefined(html5Mode.requireBase) &&
604+
isBoolean(html5Mode.requireBase)
605+
) {
603606
this.html5ModeConf.requireBase = html5Mode.requireBase;
604607
}
605608

606609
if (
607-
isDefined(html5Mode.enabled) &&
610+
isDefined(html5Mode.rewriteLinks) &&
608611
(isBoolean(html5Mode.rewriteLinks) || isString(html5Mode.rewriteLinks))
609612
) {
610613
this.html5ModeConf.rewriteLinks = html5Mode.rewriteLinks;

src/core/location/location.spec.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe("$location", () => {
1515

1616
// function initService(options) {
1717
// module.config(($provide, $locationProvider) => {
18-
// $locationProvider.html5Mode(options.html5Mode);
18+
// $locationProvider.setHtml5Mode(options.html5Mode);
1919
// $locationProvider.hashPrefix(options.hashPrefix);
2020
// $provide.value("$sniffer", { history: options.supportHistory });
2121
// });
@@ -24,12 +24,12 @@ describe("$location", () => {
2424
describe("defaults", () => {
2525
it('should have hashPrefix of "!"', () => {
2626
let provider = new LocationProvider();
27-
expect(provider.hashPrefix()).toBe("!");
27+
expect(provider.getHashPrefix()).toBe("!");
2828
});
2929

3030
it("should not be html5 mode", () => {
3131
let provider = new LocationProvider();
32-
expect(provider.html5Mode().enabled).toBeFalse();
32+
expect(provider.getHtml5Mode().enabled).toBeFalse();
3333
});
3434
});
3535

@@ -2947,7 +2947,7 @@ describe("$location", () => {
29472947

29482948
// it("should listen on click events on href and prevent browser default in html5 mode", () => {
29492949
// module(($locationProvider, $provide) => {
2950-
// $locationProvider.html5Mode(true);
2950+
// $locationProvider.setHtml5Mode(true);
29512951
// return function ($rootElement, $compile, $rootScope) {
29522952
// $rootElement.html('<a href="http://server/somePath">link</a>');
29532953
// $compile($rootElement)($rootScope);
@@ -3011,12 +3011,12 @@ describe("$location", () => {
30113011
describe("html5Mode", () => {
30123012
it("should set enabled, requireBase and rewriteLinks when called with object", () => {
30133013
module.config(($locationProvider) => {
3014-
$locationProvider.html5Mode({
3014+
$locationProvider.setHtml5Mode({
30153015
enabled: true,
30163016
requireBase: false,
30173017
rewriteLinks: false,
30183018
});
3019-
expect($locationProvider.html5Mode()).toEqual({
3019+
expect($locationProvider.getHtml5Mode()).toEqual({
30203020
enabled: true,
30213021
requireBase: false,
30223022
rewriteLinks: false,
@@ -3027,13 +3027,13 @@ describe("$location", () => {
30273027

30283028
it("should only overwrite existing properties if values are of the correct type", () => {
30293029
module.config(($locationProvider) => {
3030-
$locationProvider.html5Mode({
3030+
$locationProvider.setHtml5Mode({
30313031
enabled: "duh",
30323032
requireBase: "probably",
30333033
rewriteLinks: 0,
30343034
});
30353035

3036-
expect($locationProvider.html5Mode()).toEqual({
3036+
expect($locationProvider.getHtml5Mode()).toEqual({
30373037
enabled: false,
30383038
requireBase: true,
30393039
rewriteLinks: true,
@@ -3045,11 +3045,11 @@ describe("$location", () => {
30453045

30463046
it("should support setting rewriteLinks to a string", () => {
30473047
module.config(($locationProvider) => {
3048-
$locationProvider.html5Mode({
3048+
$locationProvider.setHtml5Mode({
30493049
rewriteLinks: "yes-rewrite",
30503050
});
30513051

3052-
expect($locationProvider.html5Mode().rewriteLinks).toEqual(
3052+
expect($locationProvider.getHtml5Mode().rewriteLinks).toEqual(
30533053
"yes-rewrite",
30543054
);
30553055
});
@@ -3059,11 +3059,11 @@ describe("$location", () => {
30593059

30603060
it("should not set unknown input properties to html5Mode object", () => {
30613061
module.config(($locationProvider) => {
3062-
$locationProvider.html5Mode({
3062+
$locationProvider.setHtml5Mode({
30633063
someProp: "foo",
30643064
});
30653065

3066-
expect($locationProvider.html5Mode()).toEqual({
3066+
expect($locationProvider.getHtml5Mode()).toEqual({
30673067
enabled: false,
30683068
requireBase: true,
30693069
rewriteLinks: true,
@@ -3075,7 +3075,7 @@ describe("$location", () => {
30753075

30763076
it("should default to enabled:false, requireBase:true and rewriteLinks:true", () => {
30773077
module.config(($locationProvider) => {
3078-
expect($locationProvider.html5Mode()).toEqual({
3078+
expect($locationProvider.getHtml5Mode()).toEqual({
30793079
enabled: false,
30803080
requireBase: true,
30813081
rewriteLinks: true,
@@ -3178,7 +3178,7 @@ describe("$location", () => {
31783178
// it("should complain if no base tag present", () => {
31793179
// let module = window.angular.module("test1", ["ng"]);
31803180
// module.config((_$locationProvider_) => {
3181-
// $locationProvider.html5Mode(true);
3181+
// $locationProvider.setHtml5Mode(true);
31823182
// });
31833183

31843184
// createInjector(["test1"]).invoke(($browser, $injector) => {
@@ -3191,7 +3191,7 @@ describe("$location", () => {
31913191

31923192
// it("should not complain if baseOptOut set to true in html5Mode", () => {
31933193
// module.config(($locationProvider) => {
3194-
// $locationProvider.html5Mode({
3194+
// $locationProvider.setHtml5Mode({
31953195
// enabled: true,
31963196
// requireBase: false,
31973197
// });

0 commit comments

Comments
 (0)