Skip to content

Instantly share code, notes, and snippets.

@bjartwolf
Created August 21, 2012 08:02
Show Gist options
  • Save bjartwolf/3413340 to your computer and use it in GitHub Desktop.
Save bjartwolf/3413340 to your computer and use it in GitHub Desktop.
loading and saving data
"use strict";
buster.testCase("The ViewModel", {
"setUp": function () {
// Spying on existing method
this.spy(MYAPP.services, 'load');
this.vm = new TaskListViewModel();
},
"load should be called on initialization": function () {
assert.calledOnce(MYAPP.services.load);
},
"should have one element when initialized": function () {
assert.same(this.vm.tasks().length, 1);
},
"should call save when save command is called, but not before": function () {
// replacing method with spy
MYAPP.services.save = this.spy();
refute.calledOnce(MYAPP.services.save);
this.vm.save();
assert.calledOnce(MYAPP.services.save);
},
"should call save when save command is called 2": function () {
MYAPP.services.save = this.spy();
this.vm.save();
assert.calledOnce(MYAPP.services.save);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment