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
{ | |
"room": "A1", | |
"grade": 6, | |
"teacher": { | |
"firstName": "Jane", | |
"lastName": "Smith", | |
"gender": "f" | |
}, | |
"students": [ | |
{ |
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 _ = require('underscore') | |
var expect = require('chai').expect | |
var sinon = require("sinon") | |
var sinonChai = require("sinon-chai") | |
chai.use(sinonChai) | |
var NewStudentForm = require('./NewStudentForm') | |
describe('NewStudentForm', function(){ | |
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
// Client-side | |
var validator = new NewStudentFormValidator().validate(data) | |
if (validator.isValid()) { | |
// submit form to server | |
} else { | |
// show errors to user | |
} | |
// Server-side (application route) | |
var validator = new NewStudentFormValidator().validate(data) |
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 _ = require('underscore') | |
var NewStudentFormValidator = function() { | |
this.errors = [] // for storing validation errors encountered | |
} | |
NewStudentFormValidator.prototype = _.extend(NewStudentFormValidator.prototype, { | |
validate: function(data) { | |
// call each validation method, storing |
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 myController = function(req, res) { | |
var form = new NewStudentForm(req.body).process() | |
if (form.errors.length > 0) { | |
// send the user back to the form | |
} else { | |
// send the user to the success page | |
} | |
} |
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 _ = require('underscore') | |
var NewStudentForm = function(data) { | |
this.data = data | |
this.errors = [] // for storing validation errors encountered | |
} | |
NewStudentForm.prototype = _.extend(NewStudentForm.prototype, { | |
process: function() { |
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
$('.submit').click(function(e){ | |
e.preventDefault(); | |
ev.trigger('submit'); | |
}); |
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
{ | |
"username": "natashaeng", | |
"key": "Nrcfj2KfYjUVvKMvkCsN", | |
"test_path": "selenium_test.js", | |
"browsers": [ | |
{ | |
"browser": "Firefox", | |
"browser_version": "28.0", | |
"os": "Windows", | |
"os_version": "XP", |
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
Grade.equal = function(grade1, grade2) { | |
return grade1.valueOf() === grade2.valueOf(); | |
} | |
var myFirstGrade = new Grade(0.7); | |
var mySecondGrade = new Grade(0.7); | |
Grade.equal(myFirstGrade, mySecondGrade) // => true |
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 DetermineStudentPassingStatus = require('./determineStudentPassingStatus'); | |
var Grade = require('./grade'); | |
describe('DetermineStudentPassingStatus', function(){ | |
var student = {}; | |
var determineStudentPassingStatus = new DetermineStudentPassingStatus(student); | |
describe('#fromAssignments', function(){ | |
var passing; |