Skip to content
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
50 changes: 38 additions & 12 deletions node-tests/blueprints/util-test-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@ describe('Blueprint: util-test', function() {
return emberNew();
});

it('util-test foo-bar', function() {
return emberGenerateDestroy(['util-test', 'foo-bar'], _file => {
expect(_file('tests/unit/utils/foo-bar-test.js')).to.equal(fixture('util-test/default.js'));
describe('with [email protected]', function() {
beforeEach(function() {
generateFakePackageManifest('ember-cli-qunit', '4.1.0');
});

it('util-test foo-bar', function() {
return emberGenerateDestroy(['util-test', 'foo-bar'], _file => {
expect(_file('tests/unit/utils/foo-bar-test.js')).to.equal(
fixture('util-test/default.js')
);
});
});
});

Expand Down Expand Up @@ -62,9 +70,15 @@ describe('Blueprint: util-test', function() {
return emberNew().then(() => fs.ensureDirSync('src'));
});

it('util-test foo-bar', function() {
return emberGenerateDestroy(['util-test', 'foo-bar'], _file => {
expect(_file('src/utils/foo-bar-test.js')).to.equal(fixture('util-test/default.js'));
describe('with [email protected]', function() {
beforeEach(function() {
generateFakePackageManifest('ember-cli-qunit', '4.1.0');
});

it('util-test foo-bar', function() {
return emberGenerateDestroy(['util-test', 'foo-bar'], _file => {
expect(_file('src/utils/foo-bar-test.js')).to.equal(fixture('util-test/default.js'));
});
});
});

Expand Down Expand Up @@ -101,9 +115,15 @@ describe('Blueprint: util-test', function() {
return emberNew({ target: 'addon' });
});

it('util-test foo-bar', function() {
return emberGenerateDestroy(['util-test', 'foo-bar'], _file => {
expect(_file('tests/unit/utils/foo-bar-test.js')).to.equal(fixture('util-test/dummy.js'));
describe('with [email protected]', function() {
beforeEach(function() {
generateFakePackageManifest('ember-cli-qunit', '4.1.0');
});

it('util-test foo-bar', function() {
return emberGenerateDestroy(['util-test', 'foo-bar'], _file => {
expect(_file('tests/unit/utils/foo-bar-test.js')).to.equal(fixture('util-test/dummy.js'));
});
});
});
});
Expand All @@ -113,9 +133,15 @@ describe('Blueprint: util-test', function() {
return emberNew({ target: 'addon' }).then(() => fs.ensureDirSync('src'));
});

it('util-test foo-bar', function() {
return emberGenerateDestroy(['util-test', 'foo-bar'], _file => {
expect(_file('src/utils/foo-bar-test.js')).to.equal(fixture('util-test/dummy.js'));
describe('with [email protected]', function() {
beforeEach(function() {
generateFakePackageManifest('ember-cli-qunit', '4.1.0');
});

it('util-test foo-bar', function() {
return emberGenerateDestroy(['util-test', 'foo-bar'], _file => {
expect(_file('src/utils/foo-bar-test.js')).to.equal(fixture('util-test/dummy.js'));
});
});
});
});
Expand Down
153 changes: 64 additions & 89 deletions node-tests/blueprints/util-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,58 +11,49 @@ const chai = require('ember-cli-blueprint-test-helpers/chai');
const expect = chai.expect;
const fs = require('fs-extra');

const generateFakePackageManifest = require('../helpers/generate-fake-package-manifest');
const fixture = require('../helpers/fixture');

describe('Blueprint: util', function() {
setupTestHooks(this);

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

it('util foo-bar', function() {
return emberGenerateDestroy(['util', 'foo-bar'], _file => {
expect(_file('app/utils/foo-bar.js')).to.contain(
'export default function fooBar() {\n' + ' return true;\n' + '}'
);
expect(_file('app/utils/foo-bar.js')).to.equal(fixture('util/util.js'));

expect(_file('tests/unit/utils/foo-bar-test.js')).to.contain(
"import fooBar from 'my-app/utils/foo-bar';"
);
expect(_file('tests/unit/utils/foo-bar-test.js')).to.equal(fixture('util-test/default.js'));
});
});

it('util foo-bar/baz', function() {
it('util foo/bar-baz', function() {
return emberGenerateDestroy(['util', 'foo/bar-baz'], _file => {
expect(_file('app/utils/foo/bar-baz.js')).to.contain(
'export default function fooBarBaz() {\n' + ' return true;\n' + '}'
);
expect(_file('app/utils/foo/bar-baz.js')).to.equal(fixture('util/util-nested.js'));

expect(_file('tests/unit/utils/foo/bar-baz-test.js')).to.contain(
"import fooBarBaz from 'my-app/utils/foo/bar-baz';"
expect(_file('tests/unit/utils/foo/bar-baz-test.js')).to.equal(
fixture('util-test/default-nested.js')
);
});
});

it('util foo-bar --pod', function() {
return emberGenerateDestroy(['util', 'foo-bar', '--pod'], _file => {
expect(_file('app/utils/foo-bar.js')).to.contain(
'export default function fooBar() {\n' + ' return true;\n' + '}'
);
expect(_file('app/utils/foo-bar.js')).to.equal(fixture('util/util.js'));

expect(_file('tests/unit/utils/foo-bar-test.js')).to.contain(
"import fooBar from 'my-app/utils/foo-bar';"
);
expect(_file('tests/unit/utils/foo-bar-test.js')).to.equal(fixture('util-test/default.js'));
});
});

it('util foo-bar/baz --pod', function() {
it('util foo/bar-baz --pod', function() {
return emberGenerateDestroy(['util', 'foo/bar-baz', '--pod'], _file => {
expect(_file('app/utils/foo/bar-baz.js')).to.contain(
'export default function fooBarBaz() {\n' + ' return true;\n' + '}'
);
expect(_file('app/utils/foo/bar-baz.js')).to.equal(fixture('util/util-nested.js'));

expect(_file('tests/unit/utils/foo/bar-baz-test.js')).to.contain(
"import fooBarBaz from 'my-app/utils/foo/bar-baz';"
expect(_file('tests/unit/utils/foo/bar-baz-test.js')).to.equal(
fixture('util-test/default-nested.js')
);
});
});
Expand All @@ -74,12 +65,10 @@ describe('Blueprint: util', function() {

it('util foo-bar --pod', function() {
return emberGenerateDestroy(['util', 'foo-bar', '--pod'], _file => {
expect(_file('app/utils/foo-bar.js')).to.contain(
'export default function fooBar() {\n' + ' return true;\n' + '}'
);
expect(_file('app/utils/foo-bar.js')).to.equal(fixture('util/util.js'));

expect(_file('tests/unit/utils/foo-bar-test.js')).to.contain(
"import fooBar from 'my-app/utils/foo-bar';"
expect(_file('tests/unit/utils/foo-bar-test.js')).to.equal(
fixture('util-test/default.js')
);
});
});
Expand All @@ -88,29 +77,25 @@ describe('Blueprint: util', function() {

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

it('util foo-bar', function() {
return emberGenerateDestroy(['util', 'foo-bar'], _file => {
expect(_file('src/utils/foo-bar.js')).to.contain(
'export default function fooBar() {\n' + ' return true;\n' + '}'
);
expect(_file('src/utils/foo-bar.js')).to.equal(fixture('util/util.js'));

expect(_file('src/utils/foo-bar-test.js')).to.contain(
"import fooBar from 'my-app/utils/foo-bar';"
);
expect(_file('src/utils/foo-bar-test.js')).to.equal(fixture('util-test/default.js'));
});
});

it('util foo-bar/baz', function() {
it('util foo/bar-baz', function() {
return emberGenerateDestroy(['util', 'foo/bar-baz'], _file => {
expect(_file('src/utils/foo/bar-baz.js')).to.contain(
'export default function fooBarBaz() {\n' + ' return true;\n' + '}'
);
expect(_file('src/utils/foo/bar-baz.js')).to.equal(fixture('util/util-nested.js'));

expect(_file('src/utils/foo/bar-baz-test.js')).to.contain(
"import fooBarBaz from 'my-app/utils/foo/bar-baz';"
expect(_file('src/utils/foo/bar-baz-test.js')).to.equal(
fixture('util-test/default-nested.js')
);
});
});
Expand All @@ -125,69 +110,63 @@ describe('Blueprint: util', function() {

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

it('util foo-bar', function() {
return emberGenerateDestroy(['util', 'foo-bar'], _file => {
expect(_file('addon/utils/foo-bar.js')).to.contain(
'export default function fooBar() {\n' + ' return true;\n' + '}'
);
expect(_file('addon/utils/foo-bar.js')).to.equal(fixture('util/util.js'));

expect(_file('app/utils/foo-bar.js')).to.contain(
"export { default } from 'my-addon/utils/foo-bar';"
);

expect(_file('tests/unit/utils/foo-bar-test.js')).to.contain(
"import fooBar from 'dummy/utils/foo-bar';"
expect(_file('tests/unit/utils/foo-bar-test.js')).to.equal(
fixture('util-test/addon-default.js')
);
});
});

it('util foo-bar/baz', function() {
it('util foo/bar-baz', function() {
return emberGenerateDestroy(['util', 'foo/bar-baz'], _file => {
expect(_file('addon/utils/foo/bar-baz.js')).to.contain(
'export default function fooBarBaz() {\n' + ' return true;\n' + '}'
);
expect(_file('addon/utils/foo/bar-baz.js')).to.equal(fixture('util/util-nested.js'));

expect(_file('app/utils/foo/bar-baz.js')).to.contain(
"export { default } from 'my-addon/utils/foo/bar-baz';"
);

expect(_file('tests/unit/utils/foo/bar-baz-test.js')).to.contain(
"import fooBarBaz from 'dummy/utils/foo/bar-baz';"
expect(_file('tests/unit/utils/foo/bar-baz-test.js')).to.equal(
fixture('util-test/addon-default-nested.js')
);
});
});
});

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

it('util foo-bar', function() {
return emberGenerateDestroy(['util', 'foo-bar'], _file => {
expect(_file('src/utils/foo-bar.js')).to.contain(
'export default function fooBar() {\n' + ' return true;\n' + '}'
);
expect(_file('src/utils/foo-bar.js')).to.equal(fixture('util/util.js'));

expect(_file('src/utils/foo-bar-test.js')).to.contain(
"import fooBar from 'dummy/utils/foo-bar';"
);
expect(_file('src/utils/foo-bar-test.js')).to.equal(fixture('util-test/addon-default.js'));

expect(_file('app/utils/foo-bar.js')).to.not.exist;
});
});

it('util foo-bar/baz', function() {
return emberGenerateDestroy(['util', 'foo/bar-baz'], _file => {
expect(_file('src/utils/foo/bar-baz.js')).to.contain(
'export default function fooBarBaz() {\n' + ' return true;\n' + '}'
);
expect(_file('src/utils/foo/bar-baz.js')).to.equal(fixture('util/util-nested.js'));

expect(_file('src/utils/foo/bar-baz-test.js')).to.contain(
"import fooBarBaz from 'dummy/utils/foo/bar-baz';"
expect(_file('src/utils/foo/bar-baz-test.js')).to.equal(
fixture('util-test/addon-default-nested.js')
);

expect(_file('app/utils/foo/bar-baz.js')).to.not.exist;
Expand All @@ -197,40 +176,36 @@ describe('Blueprint: util', 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('util foo --in-repo-addon=my-addon', function() {
return emberGenerateDestroy(['util', 'foo', '--in-repo-addon=my-addon'], _file => {
expect(_file('lib/my-addon/addon/utils/foo.js')).to.contain(
'export default function foo() {\n' + ' return true;\n' + '}'
);
it('util foo-bar --in-repo-addon=my-addon', function() {
return emberGenerateDestroy(['util', 'foo-bar', '--in-repo-addon=my-addon'], _file => {
expect(_file('lib/my-addon/addon/utils/foo-bar.js')).to.equal(fixture('util/util.js'));

expect(_file('lib/my-addon/app/utils/foo.js')).to.contain(
"export { default } from 'my-addon/utils/foo';"
expect(_file('lib/my-addon/app/utils/foo-bar.js')).to.contain(
"export { default } from 'my-addon/utils/foo-bar';"
);

expect(_file('tests/unit/utils/foo-test.js'))
.to.contain("import foo from 'my-app/utils/foo';")
.to.contain("import { module, test } from 'qunit';")
.to.contain("module('Unit | Utility | foo');");
expect(_file('tests/unit/utils/foo-bar-test.js')).to.equal(fixture('util-test/default.js'));
});
});

it('util foo/bar --in-repo-addon=my-addon', function() {
return emberGenerateDestroy(['util', 'foo/bar', '--in-repo-addon=my-addon'], _file => {
expect(_file('lib/my-addon/addon/utils/foo/bar.js')).to.contain(
'export default function fooBar() {\n' + ' return true;\n' + '}'
it('util foo/bar-baz --in-repo-addon=my-addon', function() {
return emberGenerateDestroy(['util', 'foo/bar-baz', '--in-repo-addon=my-addon'], _file => {
expect(_file('lib/my-addon/addon/utils/foo/bar-baz.js')).to.equal(
fixture('util/util-nested.js')
);

expect(_file('lib/my-addon/app/utils/foo/bar.js')).to.contain(
"export { default } from 'my-addon/utils/foo/bar';"
expect(_file('lib/my-addon/app/utils/foo/bar-baz.js')).to.contain(
"export { default } from 'my-addon/utils/foo/bar-baz';"
);

expect(_file('tests/unit/utils/foo/bar-test.js'))
.to.contain("import fooBar from 'my-app/utils/foo/bar';")
.to.contain("import { module, test } from 'qunit';")
.to.contain("module('Unit | Utility | foo/bar');");
expect(_file('tests/unit/utils/foo/bar-baz-test.js')).to.equal(
fixture('util-test/default-nested.js')
);
});
});
});
Expand Down
10 changes: 10 additions & 0 deletions node-tests/fixtures/util-test/addon-default-nested.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import fooBarBaz from 'dummy/utils/foo/bar-baz';
import { module, test } from 'qunit';

module('Unit | Utility | foo/bar-baz');

// Replace this with your real tests.
test('it works', function(assert) {
let result = fooBarBaz();
assert.ok(result);
});
10 changes: 10 additions & 0 deletions node-tests/fixtures/util-test/addon-default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import fooBar from 'dummy/utils/foo-bar';
import { module, test } from 'qunit';

module('Unit | Utility | foo-bar');

// Replace this with your real tests.
test('it works', function(assert) {
let result = fooBar();
assert.ok(result);
});
10 changes: 10 additions & 0 deletions node-tests/fixtures/util-test/default-nested.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import fooBarBaz from 'my-app/utils/foo/bar-baz';
import { module, test } from 'qunit';

module('Unit | Utility | foo/bar-baz');

// Replace this with your real tests.
test('it works', function(assert) {
let result = fooBarBaz();
assert.ok(result);
});
3 changes: 3 additions & 0 deletions node-tests/fixtures/util/util-nested.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function fooBarBaz() {
return true;
}
3 changes: 3 additions & 0 deletions node-tests/fixtures/util/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function fooBar() {
return true;
}