-
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.
- Loading branch information
Showing
2 changed files
with
41 additions
and
12 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
52 changes: 40 additions & 12 deletions
52
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 |
---|---|---|
@@ -1,43 +1,71 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupApplicationTest } from 'ember-qunit'; | ||
import { visit, find, click } from '@ember/test-helpers'; | ||
import { macroCondition, dependencySatisfies } from '@embroider/macros'; | ||
|
||
module('Acceptance | Engine Router Service | Refresh Method', function (hooks) { | ||
setupApplicationTest(hooks); | ||
|
||
test('refresh without params triggers refresh with current route', async function (assert) { | ||
assert.expect(1); | ||
|
||
await visit('/routable-engine-demo/ember-blog/new'); | ||
|
||
let counter = await find('.route-refresh-counter').textContent; | ||
await click('.refresh'); | ||
|
||
counter = parseInt(counter, 10); | ||
counter = ++counter; | ||
counter = counter.toString(); | ||
assert.dom('.route-refresh-counter').hasText(counter); | ||
if (macroCondition(dependencySatisfies('ember-source', '>= 4.1.0'))) { | ||
counter = parseInt(counter, 10); | ||
counter = ++counter; | ||
counter = counter.toString(); | ||
assert.dom('.route-refresh-counter').hasText(counter); | ||
} else { | ||
// eslint-disable-next-line qunit/no-conditional-assertions | ||
assert.throws( | ||
'Refresh method is not available in ember-source below v4.1' | ||
); | ||
} | ||
}); | ||
|
||
test('refresh with params triggers refresh on provided route', async function (assert) { | ||
assert.expect(1); | ||
|
||
await visit('/routable-engine-demo/ember-blog/new'); | ||
|
||
let counter = await find('.route-refresh-counter').textContent; | ||
await click('.refresh-route'); | ||
|
||
counter = parseInt(counter, 10); | ||
counter = ++counter; | ||
counter = counter.toString(); | ||
assert.dom('.route-refresh-counter').hasText(counter); | ||
if (macroCondition(dependencySatisfies('ember-source', '>= 4.1.0'))) { | ||
counter = parseInt(counter, 10); | ||
counter = ++counter; | ||
counter = counter.toString(); | ||
assert.dom('.route-refresh-counter').hasText(counter); | ||
} else { | ||
// eslint-disable-next-line qunit/no-conditional-assertions | ||
assert.throws( | ||
'Refresh method is not available in ember-source below v4.1' | ||
); | ||
} | ||
}); | ||
|
||
test('refresh external route', async function (assert) { | ||
assert.expect(1); | ||
|
||
await visit('/routable-engine-demo/ember-blog/new'); | ||
|
||
let counter = await find('.route-refresh-counter').textContent; | ||
await click('.refresh-external'); | ||
|
||
counter = parseInt(counter, 10); | ||
counter = ++counter; | ||
counter = counter.toString(); | ||
assert.dom('.global-refresh-counter').hasText(counter); | ||
if (macroCondition(dependencySatisfies('ember-source', '>= 4.1.0'))) { | ||
counter = parseInt(counter, 10); | ||
counter = ++counter; | ||
counter = counter.toString(); | ||
assert.dom('.global-refresh-counter').hasText(counter); | ||
} else { | ||
// eslint-disable-next-line qunit/no-conditional-assertions | ||
assert.throws( | ||
'Refresh method is not available in ember-source below v4.1' | ||
); | ||
} | ||
}); | ||
}); |