Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,7 @@ moduleFor(
}
};

FooBarComponent.reopenClass({
positionalParams: ['firstPositional'],
});
FooBarComponent.positionalParams = ['firstPositional'];

this.owner.register('component:foo-bar', FooBarComponent);

Expand Down
123 changes: 62 additions & 61 deletions packages/@ember/routing/tests/location/history_location_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,16 @@ moduleFor(
['@test HistoryLocation initState does not get fired on init'](assert) {
assert.expect(1);

HistoryTestLocation.reopen({
HistoryTestLocation = class extends HistoryTestLocation {
init() {
assert.ok(true, 'init was called');
this._super(...arguments);
},
super.init(...arguments);
}

initState() {
assert.ok(false, 'initState() should not be called automatically');
},
});
}
};

createLocation();
}
Expand All @@ -93,7 +94,7 @@ moduleFor(
createLocation();
location.initState();

assert.strictEqual(location.get('baseURL'), '/foo/');
assert.strictEqual(location.baseURL, '/foo/');
} finally {
document.head.removeChild(base);
}
Expand All @@ -111,7 +112,7 @@ moduleFor(
createLocation();
location.initState();

assert.strictEqual(location.get('baseURL'), '');
assert.strictEqual(location.baseURL, '');
} finally {
document.head.removeChild(base);
}
Expand All @@ -120,20 +121,20 @@ moduleFor(
['@test base URL is removed when retrieving the current pathname'](assert) {
assert.expect(1);

HistoryTestLocation.reopen({
HistoryTestLocation = class extends HistoryTestLocation {
init() {
this._super(...arguments);
super.init(...arguments);

set(this, 'location', mockBrowserLocation('/base/foo/bar'));
set(this, 'baseURL', '/base/');
},
}

initState() {
this._super(...arguments);
super.initState(...arguments);

assert.equal(this.getURL(), '/foo/bar');
},
});
}
};

createLocation();
location.initState();
Expand All @@ -142,14 +143,14 @@ moduleFor(
['@test base URL is preserved when moving around'](assert) {
assert.expect(2);

HistoryTestLocation.reopen({
HistoryTestLocation = class extends HistoryTestLocation {
init() {
this._super(...arguments);
super.init(...arguments);

set(this, 'location', mockBrowserLocation('/base/foo/bar'));
set(this, 'baseURL', '/base/');
},
});
}
};

createLocation();
location.initState();
Expand Down Expand Up @@ -184,15 +185,15 @@ moduleFor(
['@test HistoryLocation.getURL() returns the current url, excluding both rootURL and baseURL'](
assert
) {
HistoryTestLocation.reopen({
HistoryTestLocation = class extends HistoryTestLocation {
init() {
this._super(...arguments);
super.init(...arguments);

set(this, 'location', mockBrowserLocation('/base/foo/bar'));
set(this, 'rootURL', '/app/');
set(this, 'baseURL', '/base/');
},
});
}
};

createLocation();

Expand All @@ -202,14 +203,14 @@ moduleFor(
['@test HistoryLocation.getURL() returns the current url, does not remove rootURL if its not at start of url'](
assert
) {
HistoryTestLocation.reopen({
HistoryTestLocation = class extends HistoryTestLocation {
init() {
this._super(...arguments);
super.init(...arguments);

set(this, 'location', mockBrowserLocation('/foo/bar/baz'));
set(this, 'rootURL', '/bar/');
},
});
}
};

createLocation();

Expand All @@ -219,13 +220,13 @@ moduleFor(
['@test HistoryLocation.getURL() will not remove the rootURL when only a partial match'](
assert
) {
HistoryTestLocation.reopen({
HistoryTestLocation = class extends HistoryTestLocation {
init() {
this._super(...arguments);
super.init(...arguments);
set(this, 'location', mockBrowserLocation('/bars/baz'));
set(this, 'rootURL', '/bar/');
},
});
}
};

createLocation();

Expand All @@ -235,14 +236,14 @@ moduleFor(
['@test HistoryLocation.getURL() returns the current url, does not remove baseURL if its not at start of url'](
assert
) {
HistoryTestLocation.reopen({
HistoryTestLocation = class extends HistoryTestLocation {
init() {
this._super(...arguments);
super.init(...arguments);

set(this, 'location', mockBrowserLocation('/foo/bar/baz'));
set(this, 'baseURL', '/bar/');
},
});
}
};

createLocation();

Expand All @@ -252,67 +253,67 @@ moduleFor(
['@test HistoryLocation.getURL() will not remove the baseURL when only a partial match'](
assert
) {
HistoryTestLocation.reopen({
HistoryTestLocation = class extends HistoryTestLocation {
init() {
this._super(...arguments);
super.init(...arguments);
set(this, 'location', mockBrowserLocation('/bars/baz'));
set(this, 'baseURL', '/bar/');
},
});
}
};

createLocation();

assert.equal(location.getURL(), '/bars/baz');
}

['@test HistoryLocation.getURL() includes location.search'](assert) {
HistoryTestLocation.reopen({
HistoryTestLocation = class extends HistoryTestLocation {
init() {
this._super(...arguments);
super.init(...arguments);
set(this, 'location', mockBrowserLocation('/foo/bar?time=morphin'));
},
});
}
};

createLocation();

assert.equal(location.getURL(), '/foo/bar?time=morphin');
}

['@test HistoryLocation.getURL() includes location.hash'](assert) {
HistoryTestLocation.reopen({
HistoryTestLocation = class extends HistoryTestLocation {
init() {
this._super(...arguments);
super.init(...arguments);
set(this, 'location', mockBrowserLocation('/foo/bar#pink-power-ranger'));
},
});
}
};

createLocation();

assert.equal(location.getURL(), '/foo/bar#pink-power-ranger');
}

['@test HistoryLocation.getURL() includes location.hash and location.search'](assert) {
HistoryTestLocation.reopen({
HistoryTestLocation = class extends HistoryTestLocation {
init() {
this._super(...arguments);
super.init(...arguments);
set(this, 'location', mockBrowserLocation('/foo/bar?time=morphin#pink-power-ranger'));
},
});
}
};

createLocation();

assert.equal(location.getURL(), '/foo/bar?time=morphin#pink-power-ranger');
}

['@test HistoryLocation.getURL() drops duplicate slashes'](assert) {
HistoryTestLocation.reopen({
HistoryTestLocation = class extends HistoryTestLocation {
init() {
this._super(...arguments);
super.init(...arguments);
let location = mockBrowserLocation('//admin//profile//');
location.pathname = '//admin//profile//'; // mockBrowserLocation does not allow for `//`, so force it
set(this, 'location', location);
},
});
}
};

createLocation();

Expand All @@ -322,14 +323,14 @@ moduleFor(
['@test HistoryLocation.getURL() treats regex metacharacters in rootURL and baseURL literally'](
assert
) {
HistoryTestLocation.reopen({
HistoryTestLocation = class extends HistoryTestLocation {
init() {
this._super(...arguments);
super.init(...arguments);
set(this, 'location', mockBrowserLocation('/axc/secret'));
set(this, 'rootURL', '/a.c/');
set(this, 'baseURL', '/a.c/');
},
});
}
};

createLocation();

Expand All @@ -344,12 +345,12 @@ moduleFor(

FakeHistory.state = existingState;

HistoryTestLocation.reopen({
HistoryTestLocation = class extends HistoryTestLocation {
init() {
this._super(...arguments);
super.init(...arguments);
set(this, 'location', mockBrowserLocation('/route/path'));
},
});
}
};

createLocation();
location.initState();
Expand Down
Loading
Loading