-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
blueprints/instance-initializers-test: Add RFC232 variants #15945
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,29 @@ | ||||
import Application from '@ember/application'; | ||||
import { run } from '@ember/runloop'; | ||||
|
||||
import { initialize } from '<%= dasherizedModulePrefix %>/initializers/<%= dasherizedModuleName %>'; | ||||
import { module, test } from 'qunit'; | ||||
import { setupTest } from 'ember-qunit'; | ||||
import destroyApp from '../../helpers/destroy-app'; | ||||
|
||||
module('<%= friendlyTestName %>', function(hooks) { | ||||
setupTest(hooks); | ||||
|
||||
hooks.beforeEach(function() { | ||||
run(() => { | ||||
this.application = Application.create(); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you swap this to |
||||
this.application.deferReadiness(); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn’t be needed with my suggested changes |
||||
}); | ||||
}); | ||||
hooks.afterEach(function() { | ||||
destroyApp(this.application); | ||||
}); | ||||
|
||||
// Replace this with your real tests. | ||||
test('it works', function(assert) { | ||||
initialize(this.application); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instance initializers expect to receive an Ember.ApplicationInstance instance, but this is an Ember.Application instance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To fix that, you would do something like:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rwjblue Ah yeah overall my bad. So with this test,
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tested on a 2.17 application. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind pushing up your demo app so I can tinker with it to find the right combo? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I made a really bad mistake in my comment above, it should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, just tested locally, and I think that it will work once updating to |
||||
|
||||
// you would normally confirm the results of the initializer here | ||||
assert.ok(true); | ||||
}); | ||||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ const modifyPackages = blueprintHelpers.modifyPackages; | |
const chai = require('ember-cli-blueprint-test-helpers/chai'); | ||
const expect = chai.expect; | ||
|
||
const generateFakePackageManifest = require('../helpers/generate-fake-package-manifest'); | ||
const fixture = require('../helpers/fixture'); | ||
|
||
describe('Blueprint: instance-initializer-test', function() { | ||
|
@@ -26,6 +27,19 @@ describe('Blueprint: instance-initializer-test', function() { | |
}); | ||
}); | ||
|
||
describe('with [email protected]', function() { | ||
beforeEach(function() { | ||
generateFakePackageManifest('ember-cli-qunit', '4.1.1'); | ||
}); | ||
|
||
it('instance-initializer-test foo', function() { | ||
return emberGenerateDestroy(['instance-initializer-test', 'foo'], _file => { | ||
expect(_file('tests/unit/instance-initializers/foo-test.js')) | ||
.to.equal(fixture('instance-initializer-test/rfc232.js')); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('with ember-cli-mocha', function() { | ||
beforeEach(function() { | ||
modifyPackages([ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Application from '@ember/application'; | ||
import { run } from '@ember/runloop'; | ||
|
||
import { initialize } from 'my-app/initializers/foo'; | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
import destroyApp from '../../helpers/destroy-app'; | ||
|
||
module('Unit | Instance Initializer | foo', function(hooks) { | ||
setupTest(hooks); | ||
|
||
hooks.beforeEach(function() { | ||
run(() => { | ||
this.application = Application.create(); | ||
this.application.deferReadiness(); | ||
}); | ||
}); | ||
hooks.afterEach(function() { | ||
destroyApp(this.application); | ||
}); | ||
|
||
// Replace this with your real tests. | ||
test('it works', function(assert) { | ||
initialize(this.application); | ||
|
||
// you would normally confirm the results of the initializer here | ||
assert.ok(true); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn’t need to
Ember.run
here, why is this required? Is there an error or something without it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah the error I get is the
You have turned on testing mode...
error...specifically related to the Application.create() expression.