Last active
August 29, 2015 14:03
-
-
Save heymichaelp/d3b4c5f8e84aa2f18358 to your computer and use it in GitHub Desktop.
View Objects: Example Testing
This file contains hidden or 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 expect = require('chai').expect | |
var GradeReportPresenter = require('./gradeReportPresenter') | |
var Grade = require('./grade') | |
describe('GradeReportPresenter', function(){ | |
before(function(){ | |
this.student = { | |
id: '123456', | |
firstName: 'Susan', | |
lastName: 'Smith', | |
gender: 'f', | |
phone: "5551234567", | |
assignments: [ | |
{ | |
grade: new Grade(0.65) | |
}, | |
{ | |
grade: new Grade(0.83) | |
}, | |
{ | |
grade: new Grade(0.90) | |
} | |
] | |
} | |
this.presented = new GradeReportPresenter(this.student).present() | |
}) | |
it('returns only the specified properties', function(){ | |
expect(this.presented).to.have.keys('phone', 'averageGrade', 'isPassing') | |
}) | |
describe('#averageGrade', function(){ | |
it('returns the correct value', function(){ | |
expect(this.presented.averageGrade).to.equal(0.79) | |
}) | |
}) | |
describe('#isPassing', function(){ | |
it('returns the correct value', function() { | |
expect( presented.isPassing ).to.equal(true) | |
}) | |
}) | |
describe('#phone', function(){ | |
it('returns the correct value', function() { | |
expect(this.presented.phone).to.equal('555-123-4567') | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment