Skip to content

Instantly share code, notes, and snippets.

@heymichaelp
Last active August 29, 2015 14:03
Show Gist options
  • Save heymichaelp/e29dad1f3f28db7d1870 to your computer and use it in GitHub Desktop.
Save heymichaelp/e29dad1f3f28db7d1870 to your computer and use it in GitHub Desktop.
Policy Objects: Example Unit Tests
var _ = require('underscore')
var expect = require('chai').expect;
var Policy = require('./Policy');
describe('Policy', function(){
it('returns true if the object passes the policy tests', function(){
var student = {
firstName: 'John',
lastName: 'Smith',
isExpelled: false,
isSuspended: false
};
var eligibility = new Policy(student).run();
expect(eligibility).to.be.true;
});
it('returns false if the student is expelled', function(){
var expelledStudent = {
firstName: 'John',
lastName: 'Smith',
isExpelled: true,
isSuspended: false
};
var eligibility = new Policy(expelledStudent).run();
expect(eligibility).to.be.false;
});
it('returns false if the student is suspended', function(){
var suspendedStudent = {
firstName: 'John',
lastName: 'Smith',
isExpelled: false,
isSuspended: true
};
var eligibility = new Policy(suspendedStudent).run();
expect(eligibility).to.be.false;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment