Skip to content

Commit b723a43

Browse files
authored
Merge pull request ember-fastboot#778 from kiwiupover/move-package-json-test
Move package-json test to the basic-app
2 parents f80bcd8 + ff8dc4d commit b723a43

File tree

14 files changed

+242
-244
lines changed

14 files changed

+242
-244
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"private": true,
44
"workspaces": [
55
"packages/ember-cli-fastboot",
6-
"test-packages/basic-app"
6+
"test-packages/basic-app",
7+
"test-packages/*"
78
]
89
}

packages/ember-cli-fastboot/test/fixtures/module-whitelist/README.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/ember-cli-fastboot/test/fixtures/module-whitelist/config/environment.js

Lines changed: 0 additions & 51 deletions
This file was deleted.

packages/ember-cli-fastboot/test/fixtures/module-whitelist/ember-cli-build.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/ember-cli-fastboot/test/fixtures/module-whitelist/node_modules/fake-addon-2/index.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/ember-cli-fastboot/test/package-json-test.js

Lines changed: 0 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -11,170 +11,6 @@ chai.use(require('chai-fs'));
1111
describe('generating package.json', function() {
1212
this.timeout(300000);
1313

14-
let app;
15-
16-
before(function() {
17-
app = new AddonTestApp();
18-
19-
return app.create('module-whitelist', {
20-
skipNpm: true
21-
})
22-
.then(addFastBootDeps)
23-
.then(function() {
24-
return app.run('npm', 'install');
25-
});
26-
});
27-
28-
describe('with FastBoot builds', function() {
29-
30-
before(function() {
31-
return app.runEmberCommand('build');
32-
});
33-
34-
it('builds a package.json', function() {
35-
expect(app.filePath('dist/package.json')).to.be.a.file();
36-
});
37-
38-
it('merges FastBoot dependencies from multiple addons', function() {
39-
let config = fs.readJsonSync(app.filePath('/dist/package.json'));
40-
41-
expect(config.dependencies).to.deep.equal({
42-
'foo': '1.0.0',
43-
'bar': '^0.1.2',
44-
'baz': '0.0.0',
45-
"najax": "^1.0.3",
46-
'rsvp': '3.2.1'
47-
});
48-
});
49-
50-
it('contains a schema version', function() {
51-
let pkg = fs.readJsonSync(app.filePath('/dist/package.json'));
52-
53-
expect(pkg.fastboot.schemaVersion).to.deep.equal(3);
54-
});
55-
56-
it('contains a whitelist of allowed module names', function() {
57-
let pkg = fs.readJsonSync(app.filePath('/dist/package.json'));
58-
59-
expect(pkg.fastboot.moduleWhitelist).to.deep.equal([
60-
'najax',
61-
'url',
62-
'path',
63-
'foo',
64-
'bar',
65-
'baz',
66-
'rsvp'
67-
]);
68-
});
69-
70-
it('contains a manifest of FastBoot assets', function() {
71-
let pkg = fs.readJsonSync(app.filePath('/dist/package.json'));
72-
73-
expect(pkg.fastboot.manifest).to.deep.equal({
74-
appFiles: ['assets/module-whitelist.js', 'assets/module-whitelist-fastboot.js', 'ember-fastboot-build-example/bar.js'],
75-
htmlFile: 'index.html',
76-
vendorFiles: ['ember-fastboot-build-example/foo.js', 'assets/vendor.js']
77-
});
78-
});
79-
80-
it('contains a list of whitelisted hosts from environment.js', function() {
81-
let pkg = fs.readJsonSync(app.filePath('dist/package.json'));
82-
83-
expect(pkg.fastboot.hostWhitelist).to.deep.equal([
84-
'example.com',
85-
'subdomain.example.com',
86-
'/localhost:\\d+/'
87-
]);
88-
});
89-
90-
it('contains app name', function() {
91-
let pkg = fs.readJsonSync(app.filePath('dist/package.json'));
92-
93-
expect(pkg.fastboot.appName).to.equal('module-whitelist');
94-
});
95-
96-
it('contains the application config', function() {
97-
let pkg = fs.readJsonSync(app.filePath('dist/package.json'));
98-
99-
expect(pkg.fastboot.config['module-whitelist']).to.deep.equal({
100-
modulePrefix: 'module-whitelist',
101-
environment: 'development',
102-
baseURL: '/',
103-
locationType: 'auto',
104-
EmberENV: { FEATURES: {} },
105-
APP: { name: 'module-whitelist', version: '0.0.0', autoboot: false },
106-
fastboot: { hostWhitelist: [ 'example.com', 'subdomain.example.com', '/localhost:\\d+/' ] },
107-
exportApplicationGlobal: true
108-
});
109-
});
110-
111-
it('contains additional config from ember-fastboot-build-example addon', function() {
112-
let pkg = fs.readJsonSync(app.filePath('dist/package.json'));
113-
114-
expect(pkg.fastboot.config['foo']).to.equal('bar');
115-
});
116-
117-
describe('with addon that implements fastbootConfigTree', function() {
118-
let app;
119-
120-
before(function() {
121-
app = new AddonTestApp();
122-
123-
return app.create('fastboot-config', {
124-
skipNpm: true
125-
})
126-
.then(addFastBootDeps)
127-
.then(function() {
128-
return app.run('npm', 'install');
129-
})
130-
.then(function() {
131-
return app.runEmberCommand('build');
132-
});
133-
});
134-
135-
it('it extends the application config', function() {
136-
let pkg = fs.readJsonSync(app.filePath('dist/package.json'));
137-
138-
expect(pkg.fastboot.config['fastboot-config']).to.deep.equal({
139-
foo: 'bar',
140-
modulePrefix: 'fastboot-config',
141-
environment: 'development',
142-
baseURL: '/',
143-
locationType: 'auto',
144-
EmberENV: { FEATURES: {} },
145-
APP: { name: 'fastboot-config', version: '0.0.0', autoboot: false },
146-
fastboot: { hostWhitelist: [ 'example.com', 'subdomain.example.com', '/localhost:\\d+/' ] },
147-
exportApplicationGlobal: true
148-
});
149-
});
150-
});
151-
});
152-
153-
describe('with production FastBoot builds', function() {
154-
155-
before(function() {
156-
return app.runEmberCommand('build', '--environment=production');
157-
});
158-
159-
it('contains a manifest of FastBoot assets', function() {
160-
let pkg = fs.readJsonSync(app.filePath('/dist/package.json'));
161-
162-
let p = function(filePath) {
163-
return app.filePath(path.join('dist', filePath));
164-
};
165-
166-
let manifest = pkg.fastboot.manifest;
167-
168-
manifest.appFiles.forEach(function(file) {
169-
expect(p(file)).to.be.a.file();
170-
});
171-
expect(p(manifest.htmlFile)).to.be.a.file();
172-
manifest.vendorFiles.forEach(function(file) {
173-
expect(p(file)).to.be.a.file();
174-
});
175-
});
176-
});
177-
17814
describe('with customized fingerprinting options', function() {
17915
// Tests an app with a custom `assetMapPath` set
18016
let customApp = new AddonTestApp();
@@ -276,14 +112,3 @@ describe('generating package.json', function() {
276112
});
277113
});
278114

279-
function addFastBootDeps(app) {
280-
return app.editPackageJSON(pkg => {
281-
pkg['devDependencies']['fake-addon'] = `*`;
282-
pkg['devDependencies']['fake-addon-2'] = `*`;
283-
pkg['fastbootDependencies'] = ["rsvp"];
284-
pkg['dependencies'] = {
285-
rsvp: '3.2.1',
286-
'ember-fastboot-build-example': '0.1.2'
287-
};
288-
});
289-
}

test-packages/basic-app/config/environment.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ module.exports = function(environment) {
2020
APP: {
2121
// Here you can pass flags/options to your application instance
2222
// when it is created
23+
},
24+
25+
fastboot: {
26+
hostWhitelist: [
27+
'example.com',
28+
'subdomain.example.com',
29+
'/localhost:\\d+/',
30+
]
2331
}
2432
};
2533

test-packages/basic-app/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
"test:ember": "ember test",
2222
"test:mocha": "mocha"
2323
},
24+
"dependencies": {
25+
"ember-fastboot-build-example": "0.1.2",
26+
"rsvp": "^4.8.5"
27+
},
2428
"devDependencies": {
2529
"@ember/optional-features": "^1.3.0",
2630
"@glimmer/component": "^1.0.0",
@@ -53,11 +57,16 @@
5357
"eslint-plugin-ember": "^8.6.0",
5458
"eslint-plugin-node": "^11.1.0",
5559
"execa": "^4.0.3",
60+
"fake-addon": "*",
61+
"fake-addon-2": "*",
5662
"loader.js": "^4.7.0",
5763
"mocha": "^8.0.1",
5864
"npm-run-all": "^4.1.5",
5965
"qunit-dom": "^1.2.0"
6066
},
67+
"fastbootDependencies": [
68+
"rsvp"
69+
],
6170
"engines": {
6271
"node": "10.* || >= 12"
6372
},

0 commit comments

Comments
 (0)