-
-
Save tirams/1834006 to your computer and use it in GitHub Desktop.
Basic Backbone View Jasmine Test
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
describe("NotesView", function() { | |
beforeEach(function() { | |
var notes = new NotesCollection(); | |
spyOn(notes, "fetch"); | |
var view = new NotesView({collection: notes}); | |
}); | |
describe("#initialize", function() { | |
it("should fetch the notes", function() { | |
expect(notes.fetch).toHaveBeenCalled(); | |
}); | |
describe("on notes fetch success", function() { | |
beforeEach(function() { | |
var request = mostRecentAjaxRequest(); | |
request.response({ | |
status: 200, | |
responseText: JSON.stringify([ | |
{body: "Blog post #1", id: "1"} | |
]) | |
}); | |
}); | |
it("should render the view", function() { | |
expect($(view.el).find(".post")).toHaveText("Blog post #1"); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment