This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Noun.js", | |
"description": "This is a REST API against the noun part of Merriam-Webster dictionary", | |
"version": "0.0.1", | |
"private": true, | |
"scripts": { | |
"start": "node app.js", | |
"test" : "./node_modules/mocha/bin/mocha -u bdd -R spec", | |
"startLocal" : "nodemon -e html app.js" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"scripts": { | |
"start": "node app.js", | |
"start_stage": "node app.js 4000", | |
"test" : "mocha -u bdd -R spec", | |
"test_watch" : "mocha -u bdd -R spec -w" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doSomething(p, callback){ | |
// does something using the p parameter | |
// maybe call some other service | |
// that takes a long time to complete | |
// when that is finally completed. | |
// it calls back | |
// by just calling the callback function | |
callback(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First I write the call without parameters | |
doSomething(); | |
// I then adds the parameters | |
doSomething(123); | |
// and the function is just another param... | |
doSomething(123, function(){}); | |
// I then create two new lines between the curlies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var should = require("should"); | |
describe("Configuration setup", function () { | |
it("loads local configuration default", function (done) { | |
var config = require("../config")(); | |
config.mode.should.equal("local"); | |
done(); // tell mocha that we're done and it can process next test | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// first just write the top level describe function | |
describe('Users'); | |
// now add an empty function to the describe function | |
describe('Users', function (){}); | |
// add two line breaks and fill the function out | |
describe('Users', function (){ | |
describe('Validation'); | |
describe('Storage'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("Users", function (){ | |
describe("Validation", function (){ | |
it("validates an email address"); | |
it("validates the presence of a name"); | |
it("validates the password"); | |
// and more | |
}); | |
describe("Storage", function (){ | |
it("stores an user"); | |
it("retrieves an user by id"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var should = require("should"); | |
var name = "marcus"; | |
name.should.equal("marcus"); | |
// You could go to town and write almost-english... | |
user.age.should.be.within(5, 50); | |
(5).should.be.within(5, 10).and.within(5, 5); | |
(99.99).should.be.approximately(100, 0.1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var should = require("should"); | |
var myObject = null; | |
// DON’T | |
// this will fail with a "TypeError: Cannot read property 'should' of null" error | |
myObject.should.exsist(); | |
// DO | |
// this is the proper way of writing an assertion for null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var name = "marcus"; | |
name.should.equal("marcus"); |
OlderNewer