-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated tests to use modern ember idioms
- Loading branch information
1 parent
5a8af63
commit 045172a
Showing
12 changed files
with
53 additions
and
68 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 was deleted.
Oops, something went wrong.
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,4 +1,3 @@ | ||
/* jshint node:true */ | ||
|
||
module.exports = { | ||
}; | ||
module.exports = {}; |
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,25 +1,26 @@ | ||
import { test } from 'qunit'; | ||
import moduleForAcceptance from '../../tests/helpers/module-for-acceptance'; | ||
import { module, test } from 'qunit'; | ||
import { visit, currentURL } from '@ember/test-helpers'; | ||
import { setupApplicationTest } from 'ember-qunit'; | ||
import { freezeDateAt, unfreezeDate } from 'ember-mockdate-shim'; | ||
|
||
moduleForAcceptance('Acceptance | index'); | ||
module('Acceptance | index', function (hooks) { | ||
setupApplicationTest(hooks); | ||
|
||
test('can visit index route with async model and freeze date in acceptance test', function(assert) { | ||
assert.expect(3); | ||
|
||
freezeDateAt('1/1/2000'); | ||
test('It mocks the date', async function (assert) { | ||
freezeDateAt('1970-08-29'); | ||
|
||
visit('/'); | ||
await visit('/'); | ||
|
||
andThen(function() { | ||
assert.equal(currentURL(), '/'); | ||
|
||
const frozenDateYear = document.getElementById('index-page').textContent.trim(); | ||
|
||
assert.equal(frozenDateYear, 2000, 'Year is the same as frozen date'); | ||
assert.dom('[data-test-dateyear]').hasText('1970'); | ||
|
||
unfreezeDate(); | ||
|
||
assert.ok(true, 'make it to the end of the acceptance test after freezing/unfreezing dates'); | ||
assert.ok( | ||
true, | ||
'make it to the end of the acceptance test after freezing/unfreezing dates' | ||
); | ||
}); | ||
}); |
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 @@ | ||
<span data-test-dateyear>{{this.dateYear}}</span> |
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,12 +1,7 @@ | ||
import Component from "@ember/component"; | ||
import layout from '../templates/components/index-page'; | ||
import Component from '@glimmer/component'; | ||
|
||
export default Component.extend({ | ||
layout, | ||
elementId: 'index-page', | ||
|
||
init() { | ||
this._super(...arguments); | ||
this.set('dateYear', new Date().getFullYear()); | ||
}, | ||
}); | ||
export default class IndexPageComponent extends Component { | ||
get dateYear() { | ||
return new Date().getFullYear(); | ||
} | ||
} |
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,11 +1,11 @@ | ||
import Route from "@ember/routing/route"; | ||
import { Promise } from "rsvp"; | ||
import { next } from "@ember/runloop"; | ||
import { Promise } from 'rsvp'; | ||
import { next } from '@ember/runloop'; | ||
import Route from '@ember/routing/route'; | ||
|
||
export default Route.extend({ | ||
export default class IndexRoute extends Route { | ||
// Return async model to test that embers run loop doesn't fall | ||
// into an infinite loop when freezing time in acceptance tests. | ||
model() { | ||
return new Promise((res => next(() => res()))); | ||
}, | ||
}); | ||
return new Promise((res) => next(() => res())); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,3 @@ | ||
{{outlet}} | ||
|
||
{{index-page}} | ||
<IndexPage /> |
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,23 +1,20 @@ | ||
import { moduleForComponent, test } from 'ember-qunit'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
import { module, test } from 'qunit'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
import { render } from '@ember/test-helpers'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { freezeDateAt, unfreezeDate } from 'ember-mockdate-shim'; | ||
|
||
moduleForComponent('index-page', 'Integration | Component | index page', { | ||
integration: true | ||
}); | ||
|
||
test('freeze `new Date()` in component integration test', function(assert) { | ||
assert.expect(2); | ||
|
||
freezeDateAt('1/1/2000'); | ||
module('Integration | Component | index-page', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
this.render(hbs`{{index-page}}`); | ||
test('freezes new Date', async function (assert) { | ||
freezeDateAt('1999-12-26'); | ||
|
||
const frozenDateYear = this.$().text().trim(); | ||
await render(hbs`<IndexPage />`); | ||
|
||
assert.equal(frozenDateYear, 2000, 'Year is the same as frozen date'); | ||
assert.dom('[data-test-dateyear]').hasText('1999'); | ||
|
||
unfreezeDate(); | ||
|
||
assert.ok(true, 'Made it to the end of the integration test') | ||
unfreezeDate(); | ||
}); | ||
}); | ||
|
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