Skip to content

Commit 9c5ab46

Browse files
committed
wip
1 parent c91689f commit 9c5ab46

File tree

24 files changed

+357
-8
lines changed

24 files changed

+357
-8
lines changed

appveyor.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ init:
77
# Test against these versions of Node.js.
88
environment:
99
matrix:
10-
- nodejs_version: "4.8.4"
1110
- nodejs_version: "6.11.4"
1211

1312
# Install scripts. (runs after repo cloning)

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@
3636
"devDependencies": {
3737
"broccoli-asset-rev": "^2.4.5",
3838
"broccoli-test-helper": "^1.2.0",
39-
"chai": "^4.1.2",
39+
"chai": "^4.2.0",
40+
"chai-fs": "^2.0.0",
4041
"co": "^4.6.0",
4142
"ember-cli": "~3.5.1",
43+
"ember-cli-addon-tests": "^0.11.0",
4244
"ember-cli-dependency-checker": "^3.0.0",
4345
"ember-cli-fastboot": "^2.0.0",
4446
"ember-cli-htmlbars": "^3.0.1",
@@ -58,6 +60,7 @@
5860
"eslint": "^5.9.0",
5961
"eslint-plugin-ember": "^6.0.1",
6062
"eslint-plugin-node": "^8.0.0",
63+
"glob": "^7.1.3",
6164
"lerna-changelog": "^0.8.2",
6265
"loader.js": "^4.2.3",
6366
"mocha": "^5.2.0"

test/fastboot-test.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
'use strict';
2+
3+
const chai = require('chai');
4+
const expect = chai.expect;
5+
chai.use(require('chai-fs'));
6+
7+
const glob = require('glob');
8+
9+
const AddonTestApp = require('ember-cli-addon-tests').AddonTestApp;
10+
11+
describe('it builds', function() {
12+
this.timeout(300000);
13+
14+
let app;
15+
16+
before(function() {
17+
app = new AddonTestApp();
18+
19+
return app.create('dummy');
20+
});
21+
22+
it('builds into dist by default', function() {
23+
return app.runEmberCommand('build').then(function() {
24+
expect(app.filePath('dist/index.html')).to.be.a.file();
25+
expect(app.filePath('dist/assets/dummy.js')).to.be.a.file();
26+
expect(app.filePath('dist/assets/vendor.js')).to.be.a.file();
27+
expect(app.filePath('dist/index.html')).to.have.content.that.match(
28+
/<!-- EMBER_CLI_FASTBOOT_BODY -->/
29+
);
30+
expect(app.filePath('dist/assets/dummy-fastboot.js')).to.be.a.file();
31+
});
32+
});
33+
34+
it('produces a production build with --environment=production', function() {
35+
return app
36+
.runEmberCommand('build', '--environment=production')
37+
.then(function() {
38+
expect(app.filePath('dist/index.html')).to.be.a.file();
39+
40+
expect(find('dist/assets/vendor-*.js')).to.be.a.file();
41+
expect(find('dist/assets/vendor-*.js')).to.match(
42+
/vendor-\w{32}/,
43+
'file name should contain MD5 fingerprint'
44+
);
45+
46+
expect(app.filePath('dist/index.html')).to.have.content.that.match(
47+
/<!-- EMBER_CLI_FASTBOOT_BODY -->/
48+
);
49+
50+
expect(find('dist/assets/dummy-fastboot-*.js')).to.be.a.file();
51+
expect(find('dist/assets/dummy-fastboot-*.js')).to.match(
52+
/dummy-fastboot-\w{32}/,
53+
'file name should contain MD5 fingerprint'
54+
);
55+
});
56+
});
57+
58+
function find(globPath) {
59+
globPath = app.filePath(globPath);
60+
let files = glob.sync(globPath);
61+
62+
expect(files.length).to.equal(1, globPath);
63+
64+
return files[0];
65+
}
66+
});

test/fixtures/dummy/app/app.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Application from '@ember/application';
2+
import Resolver from './resolver';
3+
import loadInitializers from 'ember-load-initializers';
4+
import config from './config/environment';
5+
6+
const App = Application.extend({
7+
modulePrefix: config.modulePrefix,
8+
podModulePrefix: config.podModulePrefix,
9+
Resolver
10+
});
11+
12+
loadInitializers(App, config.modulePrefix);
13+
14+
export default App;

test/fixtures/dummy/app/components/.gitkeep

Whitespace-only changes.

test/fixtures/dummy/app/controllers/.gitkeep

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import Controller from '@ember/controller';
2+
import { run } from '@ember/runloop';
3+
import fetch from 'fetch';
4+
5+
export default Controller.extend({
6+
actions: {
7+
fetchSlowData() {
8+
fetch('/slow-data.json')
9+
.then((r) => r.json(), (e) => {
10+
run(() => this.set('fetchedSlowDataFailed', true));
11+
throw e;
12+
})
13+
.then((data) => {
14+
run(() => this.setProperties({ fetchedSlowData: data, fetchedSlowDataFailed: false }));
15+
});
16+
},
17+
18+
badFetch() {
19+
fetch('http://localhost:9999') // probably there is nothing listening here :D
20+
.then((r) => r.json(), () => run(() => this.set('fetchFailed', true)));
21+
}
22+
}
23+
});

test/fixtures/dummy/app/helpers/.gitkeep

Whitespace-only changes.

test/fixtures/dummy/app/index.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>Dummy</title>
7+
<meta name="description" content="">
8+
<meta name="viewport" content="width=device-width, initial-scale=1">
9+
10+
{{content-for "head"}}
11+
12+
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
13+
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/dummy.css">
14+
15+
{{content-for "head-footer"}}
16+
</head>
17+
<body>
18+
{{content-for "body"}}
19+
20+
<script src="{{rootURL}}assets/vendor.js"></script>
21+
<script src="{{rootURL}}assets/dummy.js"></script>
22+
23+
{{content-for "body-footer"}}
24+
</body>
25+
</html>

test/fixtures/dummy/app/models/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)