Skip to content

Instantly share code, notes, and snippets.

@coffeesam
Created June 12, 2013 10:05
Show Gist options
  • Save coffeesam/5764162 to your computer and use it in GitHub Desktop.
Save coffeesam/5764162 to your computer and use it in GitHub Desktop.
Sample Mocha test
var chai = require('chai');
var should = chai.should();
var studentHelper = require('studentHelperTest').TestSuite;
var Student = require('../src/schoolRecord.js').Student;
describe('Student', function() {
var student = new(Student);
beforeEach(function() {
student.setName("Sam");
});
it('should have a name', function() {
student.name.should.equal("Sam");
studentHelper.runTest();
});
describe('when enrolled into a course', function() {
var courseName = "Uncertified JavaScript Hacking";
beforeEach(function() {
student.enroll(courseName);
});
it('should be eligible for graduation', function() {
student.course.should.be.a('string');
student.canGraduate().should.equal(courseName);
});
describe('and have completed it', function() {
beforeEach(function () {
student.completed();
});
it('should graduate and receive certificate', function(done) {
student.receiveCertificate(function(cert) {
cert.should.equal(courseName);
done();
})
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment