Created
August 21, 2012 08:02
-
-
Save bjartwolf/3413340 to your computer and use it in GitHub Desktop.
loading and saving 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
"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