-
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathember-addon-test.js
More file actions
118 lines (100 loc) · 2.9 KB
/
ember-addon-test.js
File metadata and controls
118 lines (100 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
'use strict';
const fs = require('fs-extra');
const path = require('path');
const { describe, it } = require('../helpers/mocha');
const { expect } = require('../helpers/chai');
const {
buildTmp,
commit,
processBin,
fixtureCompare: _fixtureCompare
} = require('git-fixtures');
const {
assertNoUnstaged
} = require('../helpers/assertions');
const mutatePackageJson = require('boilerplate-update/src/mutate-package-json');
const getBlueprintFilePath = require('../../src/get-blueprint-file-path');
const loadSafeBlueprintFile = require('../../src/load-safe-blueprint-file');
const saveBlueprintFile = require('../../src/save-blueprint-file');
describe(function() {
this.timeout(60e3);
let tmpPath;
async function merge({
fixturesPath,
to = '3.11.0-beta.1',
commitMessage,
beforeMerge = () => Promise.resolve()
}) {
tmpPath = await buildTmp({
fixturesPath
});
await beforeMerge();
return await (await processBin({
bin: 'ember',
args: [
'update',
`--to=${to}`
],
cwd: tmpPath,
commitMessage,
expect
})).promise;
}
function fixtureCompare({
actual = tmpPath,
mergeFixtures
}) {
let expected = mergeFixtures;
_fixtureCompare({
expect,
actual,
expected
});
}
it('works', async function() {
let {
status
} = await merge({
fixturesPath: 'test/fixtures/app/local',
commitMessage: 'my-app',
async beforeMerge() {
await mutatePackageJson(tmpPath, pkg => {
pkg.devDependencies = {
'ember-cli': pkg.devDependencies['ember-cli'],
'ember-cli-update': '',
'ember-welcome-page': ''
};
});
let nodeModules = path.join(tmpPath, 'node_modules');
await fs.ensureDir(nodeModules);
await fs.symlink(
path.resolve(__dirname, '../..'),
path.join(nodeModules, 'ember-cli-update')
);
await fs.symlink(
path.resolve(path.dirname(require.resolve('ember-cli')), '../..'),
path.join(nodeModules, 'ember-cli')
);
await commit({
m: 'my-app',
cwd: tmpPath
});
}
});
await mutatePackageJson(tmpPath, pkg => {
// The tradeoff of not npm installing is we don't get to
// test real dep upgrades, which is acceptable for the
// ember addon method.
pkg.devDependencies = require('../fixtures/app/merge/my-app/package').devDependencies;
});
let emberCliUpdateJsonPath = await getBlueprintFilePath(tmpPath);
let emberCliUpdateJson = await loadSafeBlueprintFile(emberCliUpdateJsonPath);
// remove --no-welcome
emberCliUpdateJson.blueprints[0].options = [];
await saveBlueprintFile(emberCliUpdateJsonPath, emberCliUpdateJson);
fixtureCompare({
mergeFixtures: 'test/fixtures/app/merge/my-app'
});
assertNoUnstaged(status);
});
});