Skip to content

Commit 76ec72b

Browse files
Merge pull request #301 from rykov/fix-separator
Fixed multiple custom separators
2 parents 3da3c18 + ecb1f49 commit 76ec72b

5 files changed

Lines changed: 15 additions & 9 deletions

File tree

addon/src/services/page-title.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,6 @@ export default class PageTitleService extends Service {
203203
group = [];
204204
groups.push(group);
205205
}
206-
const lastToken = group[0];
207-
if (lastToken) {
208-
token = { ...token };
209-
token.separator = lastToken.separator;
210-
}
211206
group.unshift(token);
212207
} else {
213208
if (!appending) {

test-app/app/router.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default class Router extends EmberRouter {
88

99
Router.map(function () {
1010
this.route('about', function () {
11+
this.route('policies');
1112
this.route('authors', function () {
1213
this.route('profile');
1314
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{{page-title 'Policy' separator=" * "}}
2+
{{page-title 'Terms' separator=" + "}}

test-app/tests/acceptance/posts-test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ module('Acceptance: title', function (hooks) {
3131
assert.strictEqual(getPageTitle(), 'Profile > Authors > About My App');
3232
});
3333

34+
test('multiple custom separators work', async function (assert) {
35+
await visit('/about/policies');
36+
37+
assert.strictEqual(getPageTitle(), 'Terms + Policy * About My App');
38+
});
39+
3440
test('multiple components in a row work', async function (assert) {
3541
await visit('/posts/rails-is-omakase');
3642

test-app/tests/unit/services/page-title-test.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ module('service:page-title', function (hooks) {
6969
list.push(first);
7070
list.push(second);
7171

72-
assert.strictEqual(first.separator, 'a');
73-
assert.strictEqual(second.separator, 'a');
72+
let tokens = list.get('sortedTokens');
73+
assert.strictEqual(tokens[0].separator, 'a');
74+
assert.strictEqual(tokens[1].separator, 'a');
7475
});
7576

7677
test('the separator property is not inherited if explicitly set', function (assert) {
@@ -81,8 +82,9 @@ module('service:page-title', function (hooks) {
8182
list.push(first);
8283
list.push(second);
8384

84-
assert.strictEqual(first.separator, 'a');
85-
assert.strictEqual(second.separator, 'b');
85+
let tokens = list.get('sortedTokens');
86+
assert.strictEqual(tokens[0].separator, 'b');
87+
assert.strictEqual(tokens[1].separator, 'a');
8688
});
8789

8890
test('the prepend property is inherited by the previous token', function (assert) {

0 commit comments

Comments
 (0)