Skip to content

Commit

Permalink
acceptance testing for nested addons
Browse files Browse the repository at this point in the history
  • Loading branch information
xcambar committed Jul 6, 2016
1 parent 2391e3d commit 6584bc5
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/models/addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,14 @@ var Addon = CoreObject.extend({
}
```
*/
included: function(app) {
included: function(/* app */) {
if (!this._addonsInitialized) {
// someone called `this._super.included` without `apply` (because of older
// core-object issues that prevent a "real" super call from working properly)
return;
}

this.eachAddonInvoke('included', [app]);
this.eachAddonInvoke('included', [this._findHost()]);
},

/**
Expand All @@ -446,10 +446,7 @@ var Addon = CoreObject.extend({
@param {String} [options.destDir] Destination directory, defaults to the name of the directory the asset is in
*/
import: function(asset, options) {
var app = this.app;
while (app.app) {
app = app.app;
}
var app = this._findHost();
app.import(asset, options);
},

Expand Down
59 changes: 59 additions & 0 deletions tests/acceptance/nested-addons-smoke-test-slow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
'use strict';

var path = require('path');
var fs = require('fs-extra');

var runCommand = require('../helpers/run-command');
var acceptance = require('../helpers/acceptance');
var copyFixtureFiles = require('../helpers/copy-fixture-files');
var createTestTargets = acceptance.createTestTargets;
var teardownTestTargets = acceptance.teardownTestTargets;
var linkDependencies = acceptance.linkDependencies;
var cleanupRun = acceptance.cleanupRun;

var chai = require('../chai');
var expect = chai.expect;
var file = chai.file;
var dir = chai.dir;

var appName = 'some-cool-app';

describe('Acceptance: nested-addons-smoke-test', function() {
this.timeout(360000);

before(function() {
return createTestTargets(appName);
});

after(function() {
return teardownTestTargets();
});

beforeEach(function() {
return linkDependencies(appName);
});

afterEach(function() {
return cleanupRun(appName).then(function() {
expect(dir('tmp/' + appName)).to.not.exist;
});
});

it('addons with nested addons compile correctly', function() {
return copyFixtureFiles('addon/with-nested-addons')
.then(function() {
var packageJsonPath = path.join(__dirname, '..', '..', 'tmp', appName, 'package.json');
var packageJson = fs.readJsonSync(packageJsonPath);
packageJson.devDependencies['ember-top-addon'] = 'latest';

return fs.writeJsonSync(packageJsonPath, packageJson);
})
.then(function() {
return runCommand(path.join('.', 'node_modules', 'ember-cli', 'bin', 'ember'), 'build');
})
.then(function() {
expect(file('dist/assets/vendor.js')).to.contain('INNER_ADDON_IMPORT_WITH_APP_IMPORT');
expect(file('dist/assets/vendor.js')).to.contain('INNER_ADDON_IMPORT_WITH_THIS_IMPORT');
});
});
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6584bc5

Please sign in to comment.