Last active
August 29, 2015 14:02
-
-
Save heymichaelp/d3238c5f93ab1b173d6e to your computer and use it in GitHub Desktop.
Form Objects: 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 _ = 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(){ | |
describe('Valid Form Data', function(){ | |
before(function(){ | |
// spy on the this.persist method to see if it's called or not | |
this.persistSpy = sinon.spy(NewStudentForm.prototype, 'persist') | |
this.newStudentForm = new NewStudentForm({ | |
firstName: 'John', | |
lastName: 'Smith', | |
gender: 'm' | |
}).process() | |
}) | |
after(function() { | |
this.persistSpy.restore() | |
}) | |
it('persists the data', function(){ | |
expect(this.persistSpy).to.have.beenCalled | |
}) | |
it('does not have errors', function(){ | |
expect(this.newStudentForm.errors.length).to.eq(0) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment