Skip to content

Commit

Permalink
Fix test file for TDD
Browse files Browse the repository at this point in the history
  • Loading branch information
silvenon committed Nov 11, 2019
1 parent dfad63c commit 96f677a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
7 changes: 5 additions & 2 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ module.exports = class extends Generator {
}

writing() {
this.fs.copy(
this.fs.copyTpl(
this.templatePath('test.js'),
this.destinationPath('test/spec/test.js')
this.destinationPath('test/spec/test.js'),
{
ui: this.options.ui,
}
);

this.fs.copyTpl(
Expand Down
10 changes: 10 additions & 0 deletions generators/app/templates/test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
(function () {
'use strict';

<%_ if (ui === 'bdd') { -%>
describe('Give it some context', function () {
describe('maybe a bit more context here', function () {
it('should run here few assertions', function () {

});
});
});
<%_ } else if (ui === 'tdd') { -%>
suite('Give it some context', function () {
suite('maybe a bit more context here', function () {
test('should run here few assertions', function () {

});
});
});
<%_ } -%>
})();
4 changes: 4 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('mocha:app', () => {
.withOptions({ui: 'bdd'})
.on('end', () => {
assert.fileContent('test/index.html', /mocha.setup\('bdd'\)/);
assert.fileContent('test/spec/test.js', /describe/);
done()
});
});
Expand All @@ -47,6 +48,7 @@ describe('mocha:app', () => {
.withOptions({ui: 'tdd'})
.on('end', () => {
assert.fileContent('test/index.html', /mocha.setup\('tdd'\)/);
assert.fileContent('test/spec/test.js', /suite/);
done();
});
});
Expand All @@ -59,6 +61,7 @@ describe('mocha:app', () => {
.withPrompts({ui: 'bdd'})
.on('end', () => {
assert.fileContent('test/index.html', /mocha.setup\('bdd'\)/);
assert.fileContent('test/spec/test.js', /describe/);
done()
});
});
Expand All @@ -69,6 +72,7 @@ describe('mocha:app', () => {
.withPrompts({ui: 'tdd'})
.on('end', () => {
assert.fileContent('test/index.html', /mocha.setup\('tdd'\)/);
assert.fileContent('test/spec/test.js', /suite/);
done();
});
});
Expand Down

0 comments on commit 96f677a

Please sign in to comment.