Skip to content

Instantly share code, notes, and snippets.

@kimjoar
Created May 2, 2012 12:01
Show Gist options
  • Select an option

  • Save kimjoar/2576094 to your computer and use it in GitHub Desktop.

Select an option

Save kimjoar/2576094 to your computer and use it in GitHub Desktop.
Testing a view
describe('user view', function() {
it('should be able to show image', function() {
var user = {
image: "user.png"
};
var view = new UserView($('<div></div>'), user);
view.showImage();
// remember that `view.el` is a jQuery object. So now we can call
// `find` on it directly instead of looking for `img` in the entire
// DOM.
var image = view.el.find('img');
expect(image.attr("src")).toEqual("user.png");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment