Skip to content

Commit 03771b9

Browse files
authored
Merge pull request #702 from Gaurav0/update_test_blueprints
Update test blueprints
2 parents c9c3c69 + 8d203b1 commit 03771b9

8 files changed

Lines changed: 45 additions & 94 deletions

File tree

app/mixins/test-files.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
import Mixin from '@ember/object/mixin';
2+
import { camelize } from '@ember/string';
23

34
export default Mixin.create({
45
ensureTestHelperExists() {
56
this._ensureExists('tests/test-helper.js', 'test-helper');
67
},
78

8-
ensureTestStartAppHelperExists() {
9-
this._ensureExists('tests/helpers/start-app.js', 'test-start-app');
10-
},
11-
12-
ensureTestDestroyAppHelperExists() {
13-
this._ensureExists('tests/helpers/destroy-app.js', 'test-destroy-app');
14-
},
15-
16-
ensureTestModuleForAcceptanceHelperExists() {
17-
this._ensureExists('tests/helpers/module-for-acceptance.js', 'test-module-for-acceptance');
18-
},
19-
209
_ensureExists(filePath, blueprint) {
2110
if (!this.hasPath(filePath)) {
2211
const fileProperties = this.emberCli.buildProperties(blueprint);
@@ -30,7 +19,9 @@ export default Mixin.create({
3019
const splitFilePath = filePath.split('/');
3120
const file = splitFilePath[splitFilePath.length - 1];
3221
const name = file.replace('-test.js', '');
33-
return { filePath, name };
22+
let camelizedName = camelize(name);
23+
camelizedName = setCharAt(camelizedName, 0, name[0].toUpperCase());
24+
return { filePath, name, camelizedName };
3425
},
3526

3627
ensureTestingEnabled() {
@@ -44,7 +35,11 @@ export default Mixin.create({
4435

4536
const fileProperties = this.emberCli.buildProperties(blueprint, {
4637
dasherizedModuleName: name,
47-
friendlyTestDescription: 'TODO: put something here'
38+
moduleName: name,
39+
friendlyTestDescription: 'TODO: put something here',
40+
routePathName: name,
41+
controllerPathName: name,
42+
servicePathName: name,
4843
});
4944

5045
if (this.isPathInvalid(blueprint, filePath)) {
@@ -56,12 +51,19 @@ export default Mixin.create({
5651
createIntegrationTestFile(type) {
5752
this.ensureTestHelperExists();
5853
const blueprint = type + '-test';
59-
const { filePath, name } = this.calculateFileVarsForTests(blueprint);
54+
const { filePath, camelizedName } = this.calculateFileVarsForTests(blueprint);
55+
56+
let openComponent = descriptor => `<${descriptor}>`;
57+
let closeComponent = descriptor => `</${descriptor}>`;
58+
let selfCloseComponent = descriptor => `<${descriptor} />`;
6059

6160
const fileProperties = this.emberCli.buildProperties(blueprint, {
6261
testType: 'integration',
63-
componentPathName: name,
64-
friendlyTestDescription: 'TODO: put something here'
62+
componentName: camelizedName,
63+
friendlyTestDescription: 'TODO: put something here',
64+
openComponent,
65+
closeComponent,
66+
selfCloseComponent
6567
});
6668

6769
if (this.isPathInvalid(blueprint, filePath)) {
@@ -72,9 +74,6 @@ export default Mixin.create({
7274

7375
createAcceptanceTestFile() {
7476
this.ensureTestHelperExists();
75-
this.ensureTestStartAppHelperExists();
76-
this.ensureTestDestroyAppHelperExists();
77-
this.ensureTestModuleForAcceptanceHelperExists();
7877
const blueprint = 'acceptance-test';
7978
const { filePath, name } = this.calculateFileVarsForTests(blueprint);
8079

@@ -90,3 +89,8 @@ export default Mixin.create({
9089
this.createFile(filePath, fileProperties);
9190
}
9291
});
92+
93+
function setCharAt(str, index, char) {
94+
if(index > str.length-1) return str;
95+
return str.substr(0,index) + char + str.substr(index+1);
96+
}

app/services/ember-cli.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,6 @@ const availableBlueprints = {
112112
blueprint: 'test-helper',
113113
filePath: 'tests/test-helper.js'
114114
},
115-
'test-start-app': {
116-
blueprint: 'test-start-app',
117-
filePath: 'tests/helpers/start-app.js'
118-
},
119-
'test-destroy-app': {
120-
blueprint: 'test-destroy-app',
121-
filePath: 'tests/helpers/destroy-app.js'
122-
},
123-
'test-module-for-acceptance': {
124-
blueprint: 'test-module-for-acceptance',
125-
filePath: 'tests/helpers/module-for-acceptance.js'
126-
},
127115
'controller-test': {
128116
blueprint: 'controller-test',
129117
filePath: 'tests/unit/controllers/my-controller-test.js'

blueprints/tests/helpers/destroy-app.js

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

blueprints/tests/helpers/module-for-acceptance.js

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

blueprints/tests/helpers/start-app.js

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

blueprints/tests/test-helper.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import Application from '../app';
22
import config from '../config/environment';
33
import { setApplication } from '@ember/test-helpers';
4-
import { start } from 'ember-qunit';
54
import { assign } from '@ember/polyfills';
5+
import { start } from 'ember-qunit';
6+
7+
let attributes = {
8+
rootElement: '#test-root',
9+
autoboot: false
10+
};
11+
attributes = assign(attributes, config.APP);
612

7-
let attributes = assign({ rootElement: '#main' }, config.APP);
8-
setApplication(Application.create(attributes));
13+
let application = Application.create(attributes);
14+
setApplication(application);
915

1016
start();

lib/get-ember-cli-blueprints.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ function getEmberCLIBlueprints() {
1616
"router": "app/files/app/router.js"
1717
}
1818
},
19+
"emberBlueprintFiles": {
20+
"path": "node_modules/ember-source",
21+
"files": {
22+
'controller-test': 'controller-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js',
23+
'route-test': 'route-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js',
24+
'service-test': 'service-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js',
25+
'component-test': 'component-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js',
26+
'acceptance-test': 'acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.js'
27+
}
28+
},
1929
"legacyBlueprintFiles": {
2030
"path": path.dirname(require.resolve('ember-cli-legacy-blueprints')),
2131
"files": {
@@ -25,12 +35,7 @@ function getEmberCLIBlueprints() {
2535
'route': 'route/files/__root__/__path__/__name__.js',
2636
'service': 'service/files/__root__/__path__/__name__.js',
2737
'template': 'template/files/__root__/__path__/__name__.hbs',
28-
'helper': 'helper/files/__root__/helpers/__name__.js',
29-
'controller-test': 'controller-test/qunit-files/tests/unit/__path__/__test__.js',
30-
'route-test': 'route-test/qunit-files/tests/unit/__path__/__test__.js',
31-
'service-test': 'service-test/qunit-files/tests/unit/__path__/__test__.js',
32-
'component-test': 'component-test/qunit-files/tests/__testType__/__path__/__test__.js',
33-
'acceptance-test': 'acceptance-test/qunit-files/tests/acceptance/__name__-test.js'
38+
'helper': 'helper/files/__root__/helpers/__name__.js'
3439
}
3540
}
3641
}
@@ -56,9 +61,6 @@ function getEmberCLIBlueprints() {
5661
fileMap['app.css'] = fs.readFileSync('blueprints/app.css').toString();
5762
fileMap['index.html'] = fs.readFileSync('blueprints/index.html').toString();
5863
fileMap['test-helper'] = fs.readFileSync('blueprints/tests/test-helper.js').toString();
59-
fileMap['test-start-app'] = fs.readFileSync('blueprints/tests/helpers/start-app.js').toString();
60-
fileMap['test-destroy-app'] = fs.readFileSync('blueprints/tests/helpers/destroy-app.js').toString();
61-
fileMap['test-module-for-acceptance'] = fs.readFileSync('blueprints/tests/helpers/module-for-acceptance.js').toString();
6264
fileMap['model'] = fs.readFileSync('blueprints/model.js').toString();
6365

6466
return 'export default ' + JSON.stringify(fileMap);

tests/acceptance/gist-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ module('Acceptance | gist', function(hooks) {
289289
await click(firstFilePicker());
290290

291291
let numFiles = firstFilePickerFiles().length;
292-
assert.equal(numFiles, origFileCount + 5, 'Added 5 test files');
292+
assert.equal(numFiles, origFileCount + 2, 'Added 2 test files');
293293

294294
let fileNames = firstFilePickerFileNames();
295295
assert.equal(fileNames[fileNames.length - 1], promptValue, 'Added the file with the right name');

0 commit comments

Comments
 (0)