Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: provide getPageTitle test helper to consuming apps #209

Merged
merged 4 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,27 @@ module.exports = function (environment) {
};
```

### Testing
`assert` the page `title` with the supplied `getPageTitle` test helper:

```javascript
import { getPageTitle } from 'ember-page-title/test-support';

module('Acceptance | Register Page', function(hooks) {
setupApplicationTest(hooks);

test('visiting /register', async function(assert) {
const registerURL = '/register';
await visit(registerURL);

assert.equal(currentURL(), registerURL);
assert.equal(getPageTitle(), 'Register | Some Website');
});
});
```

### Deprecations
srsgores marked this conversation as resolved.
Show resolved Hide resolved

#### `page-title` Service

If you want to be notified when the page title has been updated, you can extend and override the `page-title` service and provide your own `titleDidUpdate` hook. The `titleDidUpdate` hook receives the new title as its sole argument.
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions addon-test-support/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { getPageTitle } from './get-page-title';
2 changes: 1 addition & 1 deletion tests/acceptance/posts-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import PageTitleService from 'ember-page-title/services/page-title';
import { click, find, waitUntil, visit } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { getPageTitle } from '../helpers/get-page-title';
import { getPageTitle } from 'ember-page-title/test-support';

module('Acceptance: title', function (hooks) {
setupApplicationTest(hooks);
Expand Down
2 changes: 1 addition & 1 deletion tests/fastboot/title-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { module, test } from 'qunit';
import { setup, visit } from 'ember-cli-fastboot-testing/test-support';
import { getPageTitle } from "../helpers/get-page-title"
import { getPageTitle } from 'ember-page-title/test-support';

module('FastBoot: title', function(hooks) {
setup(hooks);
Expand Down