Skip to content

Instantly share code, notes, and snippets.

@gmoeck
Created January 10, 2011 16:25
Show Gist options
  • Save gmoeck/772982 to your computer and use it in GitHub Desktop.
Save gmoeck/772982 to your computer and use it in GitHub Desktop.
var mockedSetFunction, mockedFindFunction, setMockObject, findMockObject;
module("Todos.main", {
setup: function() {
mockedSetFunction = Todos.tasksController.set; //ADDED THIS
setMockObject = CoreTest.stub('Todos.tasksController.set', function() { return YES; }); //ADDED THIS
Todos.tasksController.set = setMockObject; //ADDED THIS
mockedFindFunction = Todos.store.find;
findMockObject = CoreTest.stub('Todos.store.find', function() { return YES; });
Todos.store.find = findMockObject;
Todos.main();
},
teardown: function() {
Todos.getPath('mainPage.mainPane').remove();
Todos.tasksController.set = mockedSetFunction;//ADDED THIS
Todos.store.find = mockedFindFunction;
}
});
test("setup finding tasks", function() {
equals(findMockObject.callCount, 1, "Should delegate to the store to find the tasks");
});
test("setup tasksController content", function() {
equals(setMockObject.callCount, 1, "Should delegate to the tasksController to setup content"); //ADDED THIS
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment