Created
February 5, 2014 17:30
-
-
Save th3james/8829034 to your computer and use it in GitHub Desktop.
Mocha Stubbed save
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
suite("Page"); | |
test(".addSection adds a section and saves the page", function() { | |
var page, pageSaveStub; | |
page = new Page({ | |
sections: [] | |
}); | |
// page.save would call the server, stub it with a successful query | |
pageSaveStub = sinon.stub(page, 'save', function(attributes, options) { | |
return options.success(); | |
}); | |
page.addSection({ | |
name: 'Introduction' | |
}); | |
assert.lengthOf(page.sections, 1, "Expected the page to have 1 section"); | |
assert.ok( | |
pageSaveStub.calledOnce, | |
"Expected page.save to be called once but was called " + viewCloseSpy.callCount + " times" | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment