Created
June 12, 2013 10:05
-
-
Save coffeesam/5764162 to your computer and use it in GitHub Desktop.
Sample Mocha 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
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