Skip to content

Instantly share code, notes, and snippets.

@th3james
Created February 5, 2014 17:30
Show Gist options
  • Save th3james/8829034 to your computer and use it in GitHub Desktop.
Save th3james/8829034 to your computer and use it in GitHub Desktop.
Mocha Stubbed save
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