/spec/views/post_status_spec.js

http://github.com/bkeepers/monologue · JavaScript · 26 lines · 20 code · 5 blank · 1 comment · 0 complexity · 3a48c045bf79b3179a6f2abdc9390b38 MD5 · raw file

  1. require('/js/views/post_status.js');
  2. describe("Monologue.View.PostStatus", function() {
  3. var view, $el, collection;
  4. beforeEach(function() {
  5. $el = $("<form><textarea>See, it's not so hard!</textarea></form>");
  6. collection = new (Backbone.Collection.extend({url: '/mock'}));
  7. // prevent collection from trying to sync with the server
  8. spyOn(collection, 'create');
  9. view = new Monologue.View.PostStatus({el: $el, collection: collection});
  10. });
  11. describe("submitting the form", function() {
  12. it("creates status when submitting form", function() {
  13. $el.trigger('submit');
  14. expect(collection.create).toHaveBeenCalledWith({text: "See, it's not so hard!"});
  15. });
  16. it("clears the textarea", function() {
  17. $el.trigger('submit');
  18. expect($el.find('textarea').val()).toEqual('');
  19. });
  20. });
  21. });