Skip to content

Commit

Permalink
Tests using mocha and chai
Browse files Browse the repository at this point in the history
  • Loading branch information
carloshpds committed Dec 26, 2015
1 parent f5aabc6 commit 28740a6
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 81 deletions.
23 changes: 23 additions & 0 deletions tests/gulp/unitTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@


module.exports = function(options) {

/**
* Imports
*/
var gulp = require('gulp');
var mocha = require('gulp-mocha');
var $ = options.plugins;


function runTests (argument) {
return gulp.src(options.specFiles, {read: false})
.pipe(mocha({reporter: 'nyan'})) .on('error', options.errorHandler('Mocha')); // gulp-mocha needs filepaths so you can't have any plugins before it
}

gulp.task('test', ['scripts'], runTests);

gulp.task('test:auto', ['watchTests', 'test'], function(){
return gulp.watch(options.tmp + '/**/*.js', runTests);
});
}
41 changes: 24 additions & 17 deletions tests/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ var options = {
*/

options.modulesData = {
// newModule: {
// uses: 'newModule.js'
// },

gulp : {
uses: '../tests/node_modules/gulp'
},
karma: {
uses: '../tests/node_modules/karma'
uses: '../tests/node_modules/karma',
isEnabled: false
},

sonar: {
Expand All @@ -40,6 +39,10 @@ options.modulesData = {
projectKey : 'io.timeoutzero:basebuild-angular-tests',
projectName : 'basebuild angular tests',
projectVersion : '1.0.0',
},

unitTests: {
uses: 'gulp/unitTests.js'
}
}

Expand All @@ -48,20 +51,24 @@ if(gutil.env.prod){
options.modulesData.karma.uses = 'karma'
}

if(!gutil.env.demo){
options.modulesData.unitTests = {
addDeps: [
{ pattern: '../dist/utils.js', included: false},
// { pattern: '../node_modules/**/*.js', included: false},
'../specs/*.js',
],
// if(!gutil.env.demo){
// options.modulesData.unitTests = {
// addDeps: [
// '../dist/utils.js',
// // '../node_modules/chalk/index.js',
// '../node_modules/**/*.js',
// // { pattern: '../node_modules/**/*.js', included: false},
// '../specs/*.js'
// ],

// excludeFiles: [
// 'builds/dev/serve/app/**/init.dev.env.js',
// 'builds/dev/serve/app/**/init.prod.env.js'
// ]
// };
// }


excludeFiles: [
'builds/dev/serve/app/**/init.dev.env.js',
'builds/dev/serve/app/**/init.prod.env.js'
]
};
}

/*
==========================
Expand Down
7 changes: 3 additions & 4 deletions tests/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function(config) {

logLevel: config.LOG_ERROR,

frameworks: ['jasmine', 'browserify'],
frameworks: ['jasmine', 'requirejs'],

// files : [
// "builds/dev/serve/app/**/*.js"
Expand Down Expand Up @@ -72,13 +72,12 @@ module.exports = function(config) {
"karma-chrome-launcher",
"karma-dhtml-reporter",
'karma-nyan-reporter',
'karma-browserify'
'karma-requirejs'
],

preprocessors: {
'src/**/*.html' : ['ng-html2js'],
'../dist/**/*.js' : ['coverage', 'browserify' ],
'../node_modules/chalk/index.js' : ['browserify']
'../dist/**/*.js' : ['coverage'],
},

// generates the coverage
Expand Down
6 changes: 5 additions & 1 deletion tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
"version": "0.0.1",
"dependencies": {
"basebuild-angular": "0.11.0",
"chai": "3.4.1",
"karma-browserify": "4.4.2",
"karma-requirejs": "0.2.2",
"requirejs": "2.1.22"
"mocha": "2.3.4",
"requirejs": "2.1.22",
"sinon": "1.17.2"
},
"scripts": {
"test": "gulp test"
},
"devDependencies": {
"gulp": "3.9.0",
"gulp-mocha": "^2.2.0",
"gulp-util": "~3.0.2",
"karma": "0.13"
},
Expand Down
16 changes: 0 additions & 16 deletions tests/src/app/features/devProdTest/controller.dev.coffee

This file was deleted.

16 changes: 0 additions & 16 deletions tests/src/app/features/devProdTest/controller.prod.coffee

This file was deleted.

28 changes: 28 additions & 0 deletions tests/src/app/features/utils/module.spec.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@


describe 'Sample', ->

###*
* Global Variables
###
distPath = '../../../../../../../dist'


###*
* Imports
###
defaultOptions = do require "#{distPath}/defaults"
utilsModule = require("#{distPath}/utils")(defaultOptions)
chai = require 'chai'
assert = chai.assert


###*
* Tests
###
describe 'To get console names, should...', ->
it 'Get TimeoutZero name', ->
assert.equal utilsModule.getTimeoutZeroName(), '\u001b[37mTimeout\u001b[39m\u001b[36mZero\u001b[39m'



27 changes: 0 additions & 27 deletions tests/src/app/features/utils/sample.spec.coffee

This file was deleted.

0 comments on commit 28740a6

Please sign in to comment.