Skip to content

Commit 3fe116d

Browse files
author
Sergey Astapov
committed
Add tests for lodash.merge in fastbootConfigTree
1 parent 2ae3ea7 commit 3fe116d

8 files changed

Lines changed: 137 additions & 2 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This fixture app has an addon that implements fastbootConfigTree that extends application config in FastBoot build.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/* jshint node: true */
2+
3+
module.exports = function(environment) {
4+
var ENV = {
5+
modulePrefix: 'fastboot-config',
6+
environment: environment,
7+
baseURL: '/',
8+
locationType: 'auto',
9+
EmberENV: {
10+
FEATURES: {
11+
// Here you can enable experimental features on an ember canary build
12+
// e.g. 'with-controller': true
13+
}
14+
},
15+
16+
APP: {
17+
// Here you can pass flags/options to your application instance
18+
// when it is created
19+
},
20+
21+
fastboot: {
22+
hostWhitelist: ['example.com', 'subdomain.example.com', /localhost:\d+/]
23+
}
24+
};
25+
26+
if (environment === 'development') {
27+
// ENV.APP.LOG_RESOLVER = true;
28+
// ENV.APP.LOG_ACTIVE_GENERATION = true;
29+
// ENV.APP.LOG_TRANSITIONS = true;
30+
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
31+
// ENV.APP.LOG_VIEW_LOOKUPS = true;
32+
}
33+
34+
if (environment === 'test') {
35+
// Testem prefers this...
36+
ENV.baseURL = '/';
37+
ENV.locationType = 'none';
38+
39+
// keep test console output quieter
40+
ENV.APP.LOG_ACTIVE_GENERATION = false;
41+
ENV.APP.LOG_VIEW_LOOKUPS = false;
42+
43+
ENV.APP.rootElement = '#ember-testing';
44+
}
45+
46+
if (environment === 'production') {
47+
48+
}
49+
50+
return ENV;
51+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = function(defaults) {
2+
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
3+
var app = new EmberApp(defaults, {});
4+
5+
return app.toTree();
6+
};

test/fixtures/fastboot-config/node_modules/fake-addon-2/index.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/fixtures/fastboot-config/node_modules/fake-addon-2/package.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/fixtures/fastboot-config/node_modules/fake-addon/index.js

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/fixtures/fastboot-config/node_modules/fake-addon/package.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/package-json-test.js

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,50 @@ describe('generating package.json', function() {
9999
});
100100
});
101101

102-
it('contains additional config from addons', function() {
102+
it('contains additional config from ember-fastboot-build-example addon', function() {
103103
let pkg = fs.readJsonSync(app.filePath('dist/package.json'));
104104

105105
expect(pkg.fastboot.config['foo']).to.equal('bar');
106106
});
107107

108+
describe('with addon that implements fastbootConfigTree', function() {
109+
let app;
110+
111+
before(function() {
112+
app = new AddonTestApp();
113+
114+
return app.create('fastboot-config', {
115+
skipNpm: true
116+
})
117+
.then(addFastBootDeps)
118+
.then(function() {
119+
return app.run('npm', 'install');
120+
})
121+
.then(function() {
122+
return app.runEmberCommand('build');
123+
});
124+
});
125+
126+
it('it extends the application config', function() {
127+
let pkg = fs.readJsonSync(app.filePath('dist/package.json'));
128+
129+
expect(pkg.fastboot.config['fastboot-config']).to.deep.equal({
130+
foo: 'bar',
131+
modulePrefix: 'fastboot-config',
132+
environment: 'development',
133+
baseURL: '/',
134+
locationType: 'auto',
135+
EmberENV: { FEATURES: {} },
136+
APP: { name: 'fastboot-config', version: '0.0.0+', autoboot: false },
137+
fastboot: { hostWhitelist: [ 'example.com', 'subdomain.example.com', '/localhost:\\d+/' ] },
138+
exportApplicationGlobal: true
139+
});
140+
});
141+
});
142+
108143
it('contains app name', function() {
109144
let pkg = fs.readJsonSync(app.filePath('dist/package.json'));
110-
145+
111146
expect(pkg.fastboot.appName).to.equal('module-whitelist');
112147
});
113148
});

0 commit comments

Comments
 (0)