Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions lab-noah/gulpfile.js
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']);

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.

6 changes: 6 additions & 0 deletions lab-noah/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

const greet = require('./lib/greet.js');

greet.sayHey();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, method naming.

greet.sayBye();
12 changes: 12 additions & 0 deletions lab-noah/lib/greet.js
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}`;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay string interpolation!

};

exports.sayBye = function() {
return 'see ya later';
};
22 changes: 22 additions & 0 deletions lab-noah/package.json
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"
}
}
24 changes: 24 additions & 0 deletions lab-noah/test/greet-test.js
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(){

Choose a reason for hiding this comment

The 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(){

Choose a reason for hiding this comment

The 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');
});
});
});