Skip to content

Commit 23618e0

Browse files
authored
Merge pull request #70 from simonihmig/update-blueprints
Update blueprints
2 parents 27eee0c + 52a0014 commit 23618e0

File tree

43 files changed

+616
-107
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+616
-107
lines changed

.eslintrc.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ module.exports = {
3333
'config/**/*.js',
3434
'tests/dummy/config/**/*.js',
3535
'lib/feature-parser.js',
36-
'blueprints/*.js'
36+
'blueprints/*.js',
37+
'node-tests/**/*.js'
3738
],
3839
excludedFiles: [
3940
'app/**',
4041
'addon/**',
41-
'tests/dummy/app/**'
42+
'tests/dummy/app/**',
43+
'node-tests/fixtures/**'
4244
],
4345
parserOptions: {
4446
sourceType: 'script',
@@ -52,6 +54,14 @@ module.exports = {
5254
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
5355
// add your custom rules and overrides for node files here
5456
})
57+
},
58+
{
59+
files: [
60+
'node-tests/**/*.js'
61+
],
62+
env: {
63+
mocha: true
64+
}
5565
}
5666
]
5767
};

.npmignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
/bower_components
21
/config/ember-try.js
32
/dist
43
/tests
54
/tmp
65
**/.gitkeep
7-
.bowerrc
86
.editorconfig
97
.ember-cli
108
.eslintrc.js
@@ -19,3 +17,4 @@ testem.js
1917
.node_modules.ember-try/
2018
bower.json.ember-try
2119
package.json.ember-try
20+
/node-tests

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ env:
2525
- EMBER_TRY_SCENARIO=ember-release ANNOTATIONS=acceptance,smoke
2626
- EMBER_TRY_SCENARIO=ember-beta
2727
- EMBER_TRY_SCENARIO=ember-canary
28+
- EMBER_TRY_SCENARIO=node-tests
2829

2930
matrix:
3031
fast_finish: true

blueprints/feature-index.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
'use strict';
22

3+
const annotationMap = {
4+
acceptance: '@setupApplicationTest',
5+
integration: '@setupRenderingTest',
6+
unit: '@setupTest'
7+
};
8+
39
module.exports = {
410
description: 'Adds a feature to the project',
11+
availableOptions: [
12+
{ name: 'type', type: String, aliases: ['t'], default: 'acceptance' },
13+
],
514

615
locals(options) {
716
return {
@@ -18,7 +27,9 @@ module.exports = {
1827
return './';
1928
}
2029
return (path + '/').replace(/.+?\//g, '../');
21-
}())
30+
}()),
31+
type: options.type,
32+
annotation: annotationMap[options.type] || ''
2233
};
2334
},
2435

@@ -32,6 +43,9 @@ module.exports = {
3243
return {
3344
__folder__: function(options) {
3445
return options.locals.folder;
46+
},
47+
__type__: function(options) {
48+
return options.locals.type;
3549
}
3650
};
3751
}

blueprints/feature-unit-index.js

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import yadda from '../../helpers/yadda';
2+
import { expect } from 'chai';
3+
import { visit } from '@ember/test-helpers';
24

35
export default function() {
46
return yadda.localisation.English.library()
5-
.given('I type "Ember g feature make-feature"', function(next) {
6-
visit('/');
7-
// Add your own assert library
8-
andThen(() => next());
7+
.given('I type "Ember g feature make-feature"', async function() {
8+
await visit('/');
9+
expect(true, this.step).to.be.true;
910
})
10-
.when('I look in the folder', function(next) {
11-
// Add your own assert library
12-
next();
11+
.when('I look in the folder', function() {
12+
expect(true, this.step).to.be.true;
1313
});
1414
}

blueprints/mocha/ember-cli-yadda/files/tests/helpers/yadda-annotations.js

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import ENV from '../../config/environment';
22
import { describe } from 'mocha';
3-
import Ember from 'ember';
3+
import { setupApplicationTest, setupRenderingTest, setupTest } from 'ember-mocha';
44

55
// this logic could be anything, but in this case...
66
// if @ignore, then return skip (for backwards compatibility)
7-
// if no annotations are set in the config, run everything without an annotation (for backwards compatibility)
87
// if have annotations in config, then only run those that have a matching annotation
98
function checkAnnotations(annotations) {
109

@@ -25,17 +24,6 @@ function checkAnnotations(annotations) {
2524

2625
// no match, so don't run it
2726
return logIt;
28-
29-
} else {
30-
// no annotations set, so run it for backwards compatibility
31-
// unless it has annotations, then don't run it
32-
if (Object.keys(annotations).length) {
33-
// has annotation, so don't run it
34-
return logIt;
35-
} else {
36-
// no annotations, so test it
37-
return 'testIt'; // return something other than a function
38-
}
3927
}
4028
}
4129

@@ -45,8 +33,7 @@ function ignoreIt(testElement) {
4533
}
4634

4735
function logIt(testElement) {
48-
// change this to do what you need it to do
49-
Ember.Logger.info(`Not running or skipping: "${testElement.title}"`);
36+
console.info(`Not running or skipping: "${testElement.title}"`); // eslint-disable-line no-console
5037
}
5138

5239
// exported functions
@@ -58,4 +45,35 @@ function runScenario(featureAnnotations, scenarioAnnotations) {
5845
return checkAnnotations(scenarioAnnotations);
5946
}
6047

61-
export { runFeature, runScenario };
48+
// setup tests
49+
// you can override these function to add additional setup setups, or handle new setup related annotations
50+
function setupFeature(featureAnnotations) {
51+
return setupYaddaTest(featureAnnotations);
52+
}
53+
54+
function setupScenario(featureAnnotations, scenarioAnnotations) {
55+
let setupFn = setupYaddaTest(scenarioAnnotations);
56+
if (setupFn && (featureAnnotations.application || featureAnnotations.rendering || featureAnnotations.context)) {
57+
throw new Error('You must not assign any @application, @rendering or @context annotations to a scenario as well as its feature!');
58+
}
59+
return setupFn;
60+
}
61+
62+
function setupYaddaTest(annotations) {
63+
if (annotations.setupapplicationtest) {
64+
return setupApplicationTest;
65+
}
66+
if (annotations.setuprenderingtest) {
67+
return setupRenderingTest;
68+
}
69+
if (annotations.setuptest) {
70+
return setupTest;
71+
}
72+
}
73+
74+
export {
75+
runFeature,
76+
runScenario,
77+
setupFeature,
78+
setupScenario
79+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import yadda from '../../helpers/yadda';
2+
import { expect } from 'chai';
3+
4+
export default function() {
5+
return yadda.localisation.English.library()
6+
.given('I type "Ember g feature make-feature"', function(){
7+
expect(true, this.step).to.be.true;
8+
})
9+
.when('I look in the folder', function(){
10+
expect(true, this.step).to.be.true;
11+
});
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import yadda from '../../helpers/yadda';
2+
import { expect } from 'chai';
3+
4+
export default function() {
5+
return yadda.localisation.English.library()
6+
.given('I type "Ember g feature make-feature"', function(){
7+
expect(true, this.step).to.be.true;
8+
})
9+
.when('I look in the folder', function(){
10+
expect(true, this.step).to.be.true;
11+
});
12+
}

blueprints/qunit/feature-unit/files/tests/unit/__folder__/__name__.feature renamed to blueprints/mocha/feature/files/tests/__type__/__folder__/__name__.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<%= annotation %>
12
Feature: <%= featureName %>
23

34
Scenario: the one where I type ember g feature
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import steps from '<%= foldersUp %>steps';
2+
import { expect } from 'chai';
23

34
// step definitions that are shared between features should be moved to the
45
// tests/acceptance/steps/steps.js file
56

67
export default function() {
78
return steps()
8-
.then('I should find a file', function(next) {
9-
// Add your own assert library
10-
next();
9+
.then('I should find a file', function() {
10+
expect(true, this.step).to.be.true;
1111
});
1212
}
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import yadda from '../../helpers/yadda';
2+
import { visit } from '@ember/test-helpers';
23

34
export default function(assert) {
45
return yadda.localisation.English.library()
5-
.given('I type "Ember g feature make-feature"', function(next) {
6-
visit('/');
6+
.given('I type "Ember g feature make-feature"', async function() {
7+
await visit('/');
78
assert.ok(true, this.step);
8-
andThen(() => next());
99
})
10-
.when('I look in the folder', function(next) {
10+
.when('I look in the folder', function() {
1111
assert.ok(true, this.step);
12-
next();
1312
});
1413
}
Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import ENV from '../../config/environment';
2-
import { skip } from 'ember-qunit';
3-
import Ember from 'ember';
2+
import { skip } from 'qunit';
3+
import { setupApplicationTest, setupRenderingTest, setupTest } from 'ember-qunit';
44

55
// this logic could be anything, but in this case...
66
// if @ignore, then return skip (for backwards compatibility)
7-
// if no annotations are set in the config, run everything without an annotation (for backwards compatibility)
87
// if have annotations in config, then only run those that have a matching annotation
98
function checkAnnotations(annotations) {
109

@@ -25,27 +24,16 @@ function checkAnnotations(annotations) {
2524

2625
// no match, so don't run it
2726
return logIt;
28-
29-
} else {
30-
// no annotations set, so run it for backwards compatibility
31-
// unless it has annotations, then don't run it
32-
if (Object.keys(annotations).length) {
33-
// has annotation, so don't run it
34-
return logIt;
35-
} else {
36-
// no annotations, so test it
37-
return 'testIt'; // return something other than a function
38-
}
3927
}
4028
}
4129

4230
// call back functions
4331
function ignoreIt(testElement) {
44-
skip(`${testElement.title}`, function(assert) {});
32+
skip(`${testElement.title}`, function(/*assert*/) {});
4533
}
4634

4735
function logIt(testElement) {
48-
Ember.Logger.info(`Not running or skipping: "${testElement.title}"`);
36+
console.info(`Not running or skipping: "${testElement.title}"`); // eslint-disable-line no-console
4937
}
5038

5139
// exported functions
@@ -57,4 +45,35 @@ function runScenario(featureAnnotations, scenarioAnnotations) {
5745
return checkAnnotations(scenarioAnnotations);
5846
}
5947

60-
export { runFeature, runScenario };
48+
// setup tests
49+
// you can override these function to add additional setup setups, or handle new setup related annotations
50+
function setupFeature(featureAnnotations) {
51+
return setupYaddaTest(featureAnnotations);
52+
}
53+
54+
function setupScenario(featureAnnotations, scenarioAnnotations) {
55+
let setupFn = setupYaddaTest(scenarioAnnotations);
56+
if (setupFn && (featureAnnotations.application || featureAnnotations.rendering || featureAnnotations.context)) {
57+
throw new Error('You must not assign any @application, @rendering or @context annotations to a scenario as well as its feature!');
58+
}
59+
return setupFn;
60+
}
61+
62+
function setupYaddaTest(annotations) {
63+
if (annotations.setupapplicationtest) {
64+
return setupApplicationTest;
65+
}
66+
if (annotations.setuprenderingtest) {
67+
return setupRenderingTest;
68+
}
69+
if (annotations.setuptest) {
70+
return setupTest;
71+
}
72+
}
73+
74+
export {
75+
runFeature,
76+
runScenario,
77+
setupFeature,
78+
setupScenario
79+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import yadda from '../../helpers/yadda';
2+
3+
export default function(assert) {
4+
return yadda.localisation.English.library()
5+
.given('I type "Ember g feature make-feature"', function(){
6+
assert.ok(true, this.step);
7+
})
8+
.when('I look in the folder', function(){
9+
assert.ok(true, this.step);
10+
});
11+
}

0 commit comments

Comments
 (0)