Created
November 14, 2013 08:04
-
-
Save Madhuka/7463140 to your computer and use it in GitHub Desktop.
User.js testing with mocha
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 User(name) { | |
this.name = name; | |
} | |
User.prototype.getUserName = function() { | |
return this.name; | |
}; | |
module.exports = User; |
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 User = require("./User.js"); | |
var assert = require("assert"); | |
var user; | |
beforeEach(function() { | |
console.log('\nbefore every test :: adding user jhon to the system'); | |
user = new User('Jhon'); | |
//if all test you ned jhon user to chakc create in here | |
}) | |
afterEach(function() { | |
console.log('after every test :: removing user from the system'); | |
user = null; | |
}) | |
describe('Adding a new User', function() { | |
it('user should have a name', function() { | |
console.log('starting user testing '); | |
user.should.have.property('name', 'Jhon'); | |
console.log('end user test'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment