Skip to content

Commit

Permalink
chore: Test for Fastboot multiple title elements (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
raido authored Oct 17, 2020
1 parent ad9ef24 commit 4fa6ea8
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/dummy/app/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Ember Page Title</title>
<title data-test-ignore-for-fastboot-tests>Ember Page Title</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="This Ember.js addon provides a helper for changing the title of the page you're on.">
Expand Down
5 changes: 5 additions & 0 deletions tests/dummy/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ Router.map(function() {
this.route('feed', { path: '/feeds/:name' });
this.route('reader' );
this.route('docs', { path: '/' });
this.route('fastboot', function() {
this.route('multiple', function() {
this.route('titles');
});
});
});
3 changes: 3 additions & 0 deletions tests/dummy/app/routes/fastboot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from '@ember/routing/route';

export default class FastbootRoute extends Route {}
3 changes: 3 additions & 0 deletions tests/dummy/app/routes/fastboot/multiple.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from '@ember/routing/route';

export default class FastbootMultipleRoute extends Route {}
12 changes: 12 additions & 0 deletions tests/dummy/app/routes/fastboot/multiple/titles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Route from '@ember/routing/route';
import { Promise as EmberPromise } from 'rsvp';

export default class FastbootMultipleTitlesRoute extends Route {
model() {
return new EmberPromise(function (resolve) {
setTimeout(function () {
resolve();
}, 200);
});
}
}
2 changes: 2 additions & 0 deletions tests/dummy/app/templates/fastboot.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{page-title 'Fastboot'}}
{{outlet}}
2 changes: 2 additions & 0 deletions tests/dummy/app/templates/fastboot/multiple.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{page-title 'Multiple'}}
{{outlet}}
2 changes: 2 additions & 0 deletions tests/dummy/app/templates/fastboot/multiple/titles.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{page-title 'Titles'}}
{{outlet}}
12 changes: 12 additions & 0 deletions tests/fastboot/title-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ module('FastBoot: title', function(hooks) {
assert.equal(getPageTitle(htmlDocument), 'Profile > Authors > About My App');
});

test('rendering only single title element', async function (assert) {
assert.expect(2);
let { htmlDocument } = await visit('/fastboot/multiple/titles');

// Since for our non-fastboot vs fastboot tests we keep original <title>
// element in index.html, we simply filter it out.
let numberOfTitleElements = htmlDocument.head.querySelectorAll('title:not([data-test-ignore-for-fastboot-tests])');

assert.equal(numberOfTitleElements.length, 1);
assert.equal(getPageTitle(htmlDocument), 'Titles | Multiple | Fastboot | My App');
});

test('multiple components in a row work', async function (assert) {
assert.expect(1);
let { htmlDocument } = await visit('/posts/rails-is-omakase');
Expand Down

0 comments on commit 4fa6ea8

Please sign in to comment.