Skip to content

Commit

Permalink
Hopefully completed with 53 cases
Browse files Browse the repository at this point in the history
  • Loading branch information
reflexdemon committed Aug 1, 2015
1 parent 145c50f commit ade8faa
Show file tree
Hide file tree
Showing 7 changed files with 361 additions and 14 deletions.
100 changes: 100 additions & 0 deletions test/cases/app.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,104 @@
});
});

//Deep example
describe('Todo example', function() {
it('should not add any todo example files by default', function(done) {
testingUtil.mockPrompt({
name: 'module'
});
gulp.start('default').once('stop', function() {
mockGulpDest.assertDestNotContains({
'src/app/components/todo': [
'todo.js',
'todo.html',
'todo.css',
'todo-route.js',
'todo-controller.spec.js',
'todo-controller.js'
]
});
done();
});
});
describe('When Todo example is included', function() {
function beforeEachTODO() {
testingUtil.mockPrompt({
name: 'module',
example: ['todo']
});
}
it('should add a module specific template', function(done) {
beforeEachTODO();
gulp.start('default').once('stop', function() {
mockGulpDest.assertDestContains('src/app/components/todo/todo.html');
done();
});
});
it('should add a module definition file for the Todo module', function(done) {
beforeEachTODO();
gulp.start('default').once('stop', function() {
mockGulpDest.assertDestContains('src/app/components/todo/todo.js');
done();
});
});
it('should add a Todo controller with a corresponding test file', function(done) {
beforeEachTODO();
gulp.start('default').once('stop', function() {
mockGulpDest.assertDestContains([
'src/app/components/todo/todo-controller.js',
'src/app/components/todo/todo-controller.spec.js'
]);
done();
});
});
});
});
describe('CSS files', function() {
it('should add less stylesheets by default', function(done) {
testingUtil.mockPrompt({
name: 'module',
example: ['todo']
});
gulp.start('default').once('stop', function() {
mockGulpDest.assertDestContains([
'src/app/app.less',
'src/app/styles/_base.less',
'src/app/components/todo/todo.less'
]);
done();
});
});
it('should add LESS stylesheets when LESS is chosen', function(done) {
testingUtil.mockPrompt({
name: 'module',
csstype: 'less',
example: ['todo']
});
gulp.start('default').once('stop', function() {
mockGulpDest.assertDestContains([
'src/app/app.less',
'src/app/styles/_base.less',
'src/app/components/todo/todo.less'
]);
done();
});
});
it('should add Sass stylesheets when Sass is chosen', function(done) {
testingUtil.mockPrompt({
name: 'module',
csstype: 'sass',
example: ['todo']
});
gulp.start('default').once('stop', function() {
mockGulpDest.assertDestContains([
'src/app/app.scss',
'src/app/styles/_base.scss',
'src/app/components/todo/todo.scss'
]);
done();
});
});
});

})();
99 changes: 99 additions & 0 deletions test/cases/negative.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
(function() {
'use strict';

var common = require("../common");
var options = common.options;
var assert = common.assert;
var testingUtil = common.testingUtil;
var mockGulpDest = common.mockGulpDest;
var gulp = common.gulp;
var util = common.util;

function beforeEach() {
testingUtil.mockPrompt({
module: 'module1',
fileName: 'strangefilename',
test: true
});
util.setRuntimeMode('LIVE');
}

it('test for error constant', function(done) {
beforeEach();
assert.that(function() {
done();
gulp.start('constant', ['test']);
}).is.throwing();
});
it('test for error controller', function(done) {
beforeEach();
assert.that(function() {
done();
gulp.start('controller');
}).is.throwing();
});
it('test for error service', function(done) {
beforeEach();
assert.that(function() {
done();
gulp.start('service');
}).is.throwing();
});
it('test for error decorator', function(done) {
beforeEach();
assert.that(function() {
done();
gulp.start('decorator');
}).is.throwing();
});
it('test for error directive', function(done) {
beforeEach();
assert.that(function() {
done();
gulp.start('directive');
}).is.throwing();
});
it('test for error factory', function(done) {
beforeEach();
assert.that(function() {
done();
gulp.start('factory');
}).is.throwing();
});
it('test for error filter', function(done) {
beforeEach();
assert.that(function() {
done();
gulp.start('filter');
}).is.throwing();
});
it('test for error provider', function(done) {
beforeEach();
assert.that(function() {
done();
gulp.start('provider');
}).is.throwing();
});
it('test for error route', function(done) {
beforeEach();
assert.that(function() {
done();
gulp.start('route');
}).is.throwing();
});
it('test for error value', function(done) {
beforeEach();
assert.that(function() {
done();
gulp.start('value');
}).is.throwing();
});
it('test for error view', function(done) {
beforeEach();
assert.that(function() {
done();
gulp.start('view');
}).is.throwing();
});

})();
36 changes: 36 additions & 0 deletions test/cases/provider.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
(function() {
'use strict';

var common = require("../common");
var options = common.options;
var assert = common.assert;
var testingUtil = common.testingUtil;
var mockGulpDest = common.mockGulpDest;
var gulp = common.gulp;
var util = common.util;

function beforeEach() {
process.chdir(__dirname);
testingUtil.mockPrompt({
module: 'module1',
fileName: 'myprovider'
});
util.setRuntimeMode('TEST');
}

it('should put the provider file in the correct directory', function(done) {
beforeEach();
gulp.start('provider').once('stop', function() {
assert.that(mockGulpDest.basePath()).is.endingWith('src/app/components/module1');
done();
});
});
it('should put the correct provider filename', function(done) {
beforeEach();
gulp.start('provider').once('stop', function() {
mockGulpDest.assertDestContains('myprovider-provider.js');
done();
});
});

})();
36 changes: 36 additions & 0 deletions test/cases/service.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
(function() {
'use strict';

var common = require("../common");
var options = common.options;
var assert = common.assert;
var testingUtil = common.testingUtil;
var mockGulpDest = common.mockGulpDest;
var gulp = common.gulp;
var util = common.util;

function beforeEach() {
process.chdir(__dirname);
testingUtil.mockPrompt({
module: 'module1',
fileName: 'myservice'
});
util.setRuntimeMode('TEST');
}

it('should put the service file in the correct directory', function(done) {
beforeEach();
gulp.start('service').once('stop', function() {
assert.that(mockGulpDest.basePath()).is.endingWith('src/app/components/module1');
done();
});
});
it('should put the correct service filename', function(done) {
beforeEach();
gulp.start('service').once('stop', function() {
mockGulpDest.assertDestContains('myservice-service.js');
done();
});
});

})();
36 changes: 36 additions & 0 deletions test/cases/value.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
(function() {
'use strict';

var common = require("../common");
var options = common.options;
var assert = common.assert;
var testingUtil = common.testingUtil;
var mockGulpDest = common.mockGulpDest;
var gulp = common.gulp;
var util = common.util;

function beforeEach() {
process.chdir(__dirname);
testingUtil.mockPrompt({
module: 'module1',
fileName: 'myvalue'
});
util.setRuntimeMode('TEST');
}

it('should put the value file in the correct directory', function(done) {
beforeEach();
gulp.start('value').once('stop', function() {
assert.that(mockGulpDest.basePath()).is.endingWith('src/app/components/module1');
done();
});
});
it('should put the correct value filename', function(done) {
beforeEach();
gulp.start('value').once('stop', function() {
mockGulpDest.assertDestContains('myvalue-value.js');
done();
});
});

})();
36 changes: 36 additions & 0 deletions test/cases/view.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
(function() {
'use strict';

var common = require("../common");
var options = common.options;
var assert = common.assert;
var testingUtil = common.testingUtil;
var mockGulpDest = common.mockGulpDest;
var gulp = common.gulp;
var util = common.util;

function beforeEach() {
process.chdir(__dirname);
testingUtil.mockPrompt({
module: 'module1',
fileName: 'myview'
});
util.setRuntimeMode('TEST');
}

it('should put the view file in the correct directory', function(done) {
beforeEach();
gulp.start('view').once('stop', function() {
assert.that(mockGulpDest.basePath()).is.endingWith('src/app/components/module1');
done();
});
});
it('should put the correct view filename', function(done) {
beforeEach();
gulp.start('view').once('stop', function() {
mockGulpDest.assertDestContains('myview-view.html');
done();
});
});

})();
32 changes: 18 additions & 14 deletions test/top.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@
}, {
description: 'Test module with route generator',
testcase: './cases/module.route.spec'
}, {
description: 'Test provider generator',
testcase: './cases/provider.spec'
}, {
description: 'Test service generator',
testcase: './cases/service.spec'
}, {
description: 'Test value generator',
testcase: './cases/value.spec'
}, {
description: 'Test view generator',
testcase: './cases/view.spec'
}, {
description: 'Test Negative usecases for generator',
testcase: './cases/negative.spec'
}];

require('blanket')({
Expand All @@ -54,21 +69,10 @@
require('../slushfile');

describe('slush-angular-gulp', function() {
// before(function() {
// process.chdir(__dirname);
// });
before(function() {
console.log('Starting...');
});

function beforeEach() {
process.chdir(__dirname);
testingUtil.mockPrompt({
name: 'module',
example: ['todo'],
module: 'module1',
fileName: 'myfilename',
test: true
});
util.setRuntimeMode('TEST');
}
_.each(testSuite, function(tCase) {
importTest(tCase.description, tCase.testcase);
});
Expand Down

0 comments on commit ade8faa

Please sign in to comment.