-
Notifications
You must be signed in to change notification settings - Fork 15
add gulpfile and change assert to expect #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
|
||
const gulp = require('gulp'); | ||
const eslint = require('gulp-eslint'); | ||
const mocha = require('gulp-mocha'); | ||
|
||
gulp.task('lint', function(){ | ||
return gulp.src(['**/*.js', '!node_modules']) | ||
.pipe(eslint()) | ||
.pipe(eslint.format()) | ||
.pipe(eslint.failAfterError()); | ||
}); | ||
|
||
gulp.task('test', function(){ | ||
gulp.src('./test/*-test.js', {read: false}) | ||
.pipe(mocha({reporter: 'nyan'})); | ||
}); | ||
|
||
gulp.task('dev', function(){ | ||
gulp.watch(['**/*.js', '!node_modules/**'], ['lint', 'test']); | ||
}); | ||
|
||
gulp.task('default', ['dev']); | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
|
||
const greet = require('./lib/greet.js'); | ||
|
||
greet.sayHey(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good, method naming. |
||
greet.sayBye(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict'; | ||
|
||
module.exports = exports = {}; | ||
|
||
exports.sayHey = function(name){ | ||
if(arguments.length === 0) throw new Error('no name entered'); | ||
return `hey ${name}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yay string interpolation! |
||
}; | ||
|
||
exports.sayBye = function() { | ||
return 'see ya later'; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "demo-1", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"chai": "^3.5.0", | ||
"gulp": "^3.9.1", | ||
"gulp-eslint": "^3.0.1", | ||
"gulp-mocha": "^3.0.1", | ||
"mocha": "^3.2.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
const greet = require('../lib/greet.js'); | ||
const expect = require('chai').expect; | ||
|
||
describe('Greet Module', function(){ | ||
describe('#sayHey',function(){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great job using # before the name of the method being tested. |
||
it('should return hey noah',function(){ | ||
var result = greet.sayHey('noah'); | ||
expect(greet).to.have.property('sayHey'); | ||
expect(result).to.equal('hey noah'); | ||
}); | ||
it('should have a missing name error message', function(){ | ||
var result = greet.sayHey; | ||
expect(result).to.throw(Error); | ||
}); | ||
}); | ||
describe('#sayBye',function(){ | ||
it('should return see ya later', function(){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea to put a blank line above an it block so you can clearly find where the test begins and separate it from the describe blocks or other it blocks. |
||
var result = greet.sayBye(); | ||
expect(result).to.equal('see ya later'); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work making your default gulp task run all of your other tasks.