-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add tests for the refresh method
Showing
9 changed files
with
141 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
let count = 0; | ||
|
||
export default class extends Route { | ||
model() { | ||
return { | ||
count: count++, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,30 @@ | ||
<div class="hello-name" ...attributes> | ||
Hello, {{@name}}! | ||
<div class='hello-name' ...attributes> | ||
<span class='greeting'> | ||
Hello, | ||
{{@name}}! | ||
</span> | ||
|
||
<button | ||
class='refresh' | ||
type='button' | ||
{{on 'click' this.refresh}} | ||
> | ||
Refresh | ||
</button> | ||
|
||
<button | ||
class='refresh-route' | ||
type='button' | ||
{{on 'click' this.refreshRoute}} | ||
> | ||
Refresh Route | ||
</button> | ||
|
||
<button | ||
class='refresh-external' | ||
type='button' | ||
{{on 'click' this.refreshExternal}} | ||
> | ||
Refresh External | ||
</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { inject as service } from '@ember/service'; | ||
import Route from '@ember/routing/route'; | ||
|
||
let count = 0; | ||
|
||
export default class extends Route { | ||
@service exampleService; | ||
|
||
model() { | ||
// cause a service to be instantiated, so that our tests can | ||
// confirm that it gets cleaned up | ||
this.exampleService; | ||
|
||
return { | ||
name: 'Derek Zoolander', | ||
count: count++, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
test-app/tests/acceptance/routeable-engine-demo-refresh-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupApplicationTest } from 'ember-qunit'; | ||
import { visit, find, click } from '@ember/test-helpers'; | ||
|
||
module('Acceptance | routeless engine demo', function (hooks) { | ||
setupApplicationTest(hooks); | ||
|
||
module('Engine Router Service Refresh Method', function () { | ||
test('refresh without params triggers refresh with current route', async function (assert) { | ||
await visit('/routable-engine-demo/ember-blog/new'); | ||
|
||
let counter = await find('.route-refresh-counter').textContent; | ||
assert.dom('.route-refresh-counter').hasText(counter); | ||
await click('.refresh'); | ||
|
||
counter = parseInt(counter, 10); | ||
counter = ++counter; | ||
counter = counter.toString(); | ||
assert.dom('.route-refresh-counter').hasText(counter); | ||
}); | ||
|
||
test('refresh with params triggers refresh on provided route', async function (assert) { | ||
await visit('/routable-engine-demo/ember-blog/new'); | ||
|
||
let counter = await find('.route-refresh-counter').textContent; | ||
assert.dom('.route-refresh-counter').hasText(counter); | ||
await click('.refresh-route'); | ||
|
||
counter = parseInt(counter, 10); | ||
counter = ++counter; | ||
counter = counter.toString(); | ||
assert.dom('.route-refresh-counter').hasText(counter); | ||
}); | ||
|
||
test('refresh external route', async function (assert) { | ||
await visit('/routable-engine-demo/ember-blog/new'); | ||
|
||
let counter = await find('.route-refresh-counter').textContent; | ||
assert.dom('.global-refresh-counter').hasText(counter); | ||
await click('.refresh-external'); | ||
|
||
counter = parseInt(counter, 10); | ||
counter = ++counter; | ||
counter = counter.toString(); | ||
assert.dom('.global-refresh-counter').hasText(counter); | ||
}); | ||
}); | ||
}); |