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

Refactor instance-initializer blueprint tests to use fixtures #17205

Merged
merged 1 commit into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 11 additions & 5 deletions node-tests/blueprints/instance-initializer-test-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ describe('Blueprint: instance-initializer-test', function() {
return emberNew();
});

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/default.js')
);
describe('with [email protected]', function() {
beforeEach(function() {
generateFakePackageManifest('ember-cli-qunit', '4.1.0');
});

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/default.js')
);
});
});
});

Expand Down
133 changes: 34 additions & 99 deletions node-tests/blueprints/instance-initializer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,21 @@ const setupPodConfig = blueprintHelpers.setupPodConfig;
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', function() {
setupTestHooks(this);

describe('in app', function() {
beforeEach(function() {
return emberNew();
return emberNew().then(() => generateFakePackageManifest('ember-cli-qunit', '4.1.0'));
});

it('instance-initializer foo', function() {
return emberGenerateDestroy(['instance-initializer', 'foo'], _file => {
expect(_file('app/instance-initializers/foo.js')).to.contain(
'export function initialize(/* appInstance */) {\n' +
" // appInstance.inject('route', 'foo', 'service:foo');\n" +
'}\n' +
'\n' +
'export default {\n' +
' initialize\n' +
'};'
expect(_file('app/instance-initializers/foo.js')).to.equal(
fixture('instance-initializer/instance-initializer.js')
);

expect(_file('tests/unit/instance-initializers/foo-test.js')).to.contain(
Expand All @@ -37,14 +34,8 @@ describe('Blueprint: instance-initializer', function() {

it('instance-initializer foo/bar', function() {
return emberGenerateDestroy(['instance-initializer', 'foo/bar'], _file => {
expect(_file('app/instance-initializers/foo/bar.js')).to.contain(
'export function initialize(/* appInstance */) {\n' +
" // appInstance.inject('route', 'foo', 'service:foo');\n" +
'}\n' +
'\n' +
'export default {\n' +
' initialize\n' +
'};'
expect(_file('app/instance-initializers/foo/bar.js')).to.equal(
fixture('instance-initializer/instance-initializer-nested.js')
);

expect(_file('tests/unit/instance-initializers/foo/bar-test.js')).to.contain(
Expand All @@ -55,28 +46,16 @@ describe('Blueprint: instance-initializer', function() {

it('instance-initializer foo --pod', function() {
return emberGenerateDestroy(['instance-initializer', 'foo', '--pod'], _file => {
expect(_file('app/instance-initializers/foo.js')).to.contain(
'export function initialize(/* appInstance */) {\n' +
" // appInstance.inject('route', 'foo', 'service:foo');\n" +
'}\n' +
'\n' +
'export default {\n' +
' initialize\n' +
'};'
expect(_file('app/instance-initializers/foo.js')).to.equal(
fixture('instance-initializer/instance-initializer.js')
);
});
});

it('instance-initializer foo/bar --pod', function() {
return emberGenerateDestroy(['instance-initializer', 'foo/bar', '--pod'], _file => {
expect(_file('app/instance-initializers/foo/bar.js')).to.contain(
'export function initialize(/* appInstance */) {\n' +
" // appInstance.inject('route', 'foo', 'service:foo');\n" +
'}\n' +
'\n' +
'export default {\n' +
' initialize\n' +
'};'
expect(_file('app/instance-initializers/foo/bar.js')).to.equal(
fixture('instance-initializer/instance-initializer-nested.js')
);
});
});
Expand All @@ -88,28 +67,16 @@ describe('Blueprint: instance-initializer', function() {

it('instance-initializer foo --pod', function() {
return emberGenerateDestroy(['instance-initializer', 'foo', '--pod'], _file => {
expect(_file('app/instance-initializers/foo.js')).to.contain(
'export function initialize(/* appInstance */) {\n' +
" // appInstance.inject('route', 'foo', 'service:foo');\n" +
'}\n' +
'\n' +
'export default {\n' +
' initialize\n' +
'};'
expect(_file('app/instance-initializers/foo.js')).to.equal(
fixture('instance-initializer/instance-initializer.js')
);
});
});

it('instance-initializer foo/bar --pod', function() {
return emberGenerateDestroy(['instance-initializer', 'foo/bar', '--pod'], _file => {
expect(_file('app/instance-initializers/foo/bar.js')).to.contain(
'export function initialize(/* appInstance */) {\n' +
" // appInstance.inject('route', 'foo', 'service:foo');\n" +
'}\n' +
'\n' +
'export default {\n' +
' initialize\n' +
'};'
expect(_file('app/instance-initializers/foo/bar.js')).to.equal(
fixture('instance-initializer/instance-initializer-nested.js')
);
});
});
Expand All @@ -118,19 +85,15 @@ describe('Blueprint: instance-initializer', function() {

describe('in addon', function() {
beforeEach(function() {
return emberNew({ target: 'addon' });
return emberNew({ target: 'addon' }).then(() =>
generateFakePackageManifest('ember-cli-qunit', '4.1.0')
);
});

it('instance-initializer foo', function() {
return emberGenerateDestroy(['instance-initializer', 'foo'], _file => {
expect(_file('addon/instance-initializers/foo.js')).to.contain(
'export function initialize(/* appInstance */) {\n' +
" // appInstance.inject('route', 'foo', 'service:foo');\n" +
'}\n' +
'\n' +
'export default {\n' +
' initialize\n' +
'};'
expect(_file('addon/instance-initializers/foo.js')).to.equal(
fixture('instance-initializer/instance-initializer.js')
);

expect(_file('app/instance-initializers/foo.js')).to.contain(
Expand All @@ -143,14 +106,8 @@ describe('Blueprint: instance-initializer', function() {

it('instance-initializer foo/bar', function() {
return emberGenerateDestroy(['instance-initializer', 'foo/bar'], _file => {
expect(_file('addon/instance-initializers/foo/bar.js')).to.contain(
'export function initialize(/* appInstance */) {\n' +
" // appInstance.inject('route', 'foo', 'service:foo');\n" +
'}\n' +
'\n' +
'export default {\n' +
' initialize\n' +
'};'
expect(_file('addon/instance-initializers/foo/bar.js')).to.equal(
fixture('instance-initializer/instance-initializer-nested.js')
);

expect(_file('app/instance-initializers/foo/bar.js')).to.contain(
Expand All @@ -163,14 +120,8 @@ describe('Blueprint: instance-initializer', function() {

it('instance-initializer foo --dummy', function() {
return emberGenerateDestroy(['instance-initializer', 'foo', '--dummy'], _file => {
expect(_file('tests/dummy/app/instance-initializers/foo.js')).to.contain(
'export function initialize(/* appInstance */) {\n' +
" // appInstance.inject('route', 'foo', 'service:foo');\n" +
'}\n' +
'\n' +
'export default {\n' +
' initialize\n' +
'};'
expect(_file('tests/dummy/app/instance-initializers/foo.js')).to.equal(
fixture('instance-initializer/instance-initializer.js')
);

expect(_file('app/instance-initializers/foo.js')).to.not.exist;
Expand All @@ -181,14 +132,8 @@ describe('Blueprint: instance-initializer', function() {

it('instance-initializer foo/bar --dummy', function() {
return emberGenerateDestroy(['instance-initializer', 'foo/bar', '--dummy'], _file => {
expect(_file('tests/dummy/app/instance-initializers/foo/bar.js')).to.contain(
'export function initialize(/* appInstance */) {\n' +
" // appInstance.inject('route', 'foo', 'service:foo');\n" +
'}\n' +
'\n' +
'export default {\n' +
' initialize\n' +
'};'
expect(_file('tests/dummy/app/instance-initializers/foo/bar.js')).to.equal(
fixture('instance-initializer/instance-initializer-nested.js')
);

expect(_file('app/instance-initializers/foo/bar.js')).to.not.exist;
Expand All @@ -200,21 +145,17 @@ describe('Blueprint: instance-initializer', function() {

describe('in in-repo-addon', function() {
beforeEach(function() {
return emberNew({ target: 'in-repo-addon' });
return emberNew({ target: 'in-repo-addon' }).then(() =>
generateFakePackageManifest('ember-cli-qunit', '4.1.0')
);
});

it('instance-initializer foo --in-repo-addon=my-addon', function() {
return emberGenerateDestroy(
['instance-initializer', 'foo', '--in-repo-addon=my-addon'],
_file => {
expect(_file('lib/my-addon/addon/instance-initializers/foo.js')).to.contain(
'export function initialize(/* appInstance */) {\n' +
" // appInstance.inject('route', 'foo', 'service:foo');\n" +
'}\n' +
'\n' +
'export default {\n' +
' initialize\n' +
'};'
expect(_file('lib/my-addon/addon/instance-initializers/foo.js')).to.equal(
fixture('instance-initializer/instance-initializer.js')
);

expect(_file('lib/my-addon/app/instance-initializers/foo.js')).to.contain(
Expand All @@ -230,14 +171,8 @@ describe('Blueprint: instance-initializer', function() {
return emberGenerateDestroy(
['instance-initializer', 'foo/bar', '--in-repo-addon=my-addon'],
_file => {
expect(_file('lib/my-addon/addon/instance-initializers/foo/bar.js')).to.contain(
'export function initialize(/* appInstance */) {\n' +
" // appInstance.inject('route', 'foo', 'service:foo');\n" +
'}\n' +
'\n' +
'export default {\n' +
' initialize\n' +
'};'
expect(_file('lib/my-addon/addon/instance-initializers/foo/bar.js')).to.equal(
fixture('instance-initializer/instance-initializer.js')
);

expect(_file('lib/my-addon/app/instance-initializers/foo/bar.js')).to.contain(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function initialize(/* appInstance */) {
// appInstance.inject('route', 'foo', 'service:foo');
}

export default {
initialize
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function initialize(/* appInstance */) {
// appInstance.inject('route', 'foo', 'service:foo');
}

export default {
initialize
};