Skip to content
Extraits de code Groupes Projets
view-spec.js 2,07 ko
Newer Older
  • Learn to ignore specific revisions
  • /*   Copyright (c) 2010, Diaspora Inc.  This file is
    *   licensed under the Affero General Public License version 3 or later.  See
    *   the COPYRIGHT file.
    */
    
    describe("View", function() {
    
      it("is the object that helps the UI", function() { 
        expect(typeof View === "object").toBeTruthy();
      });
    
    
    Sarah Mei's avatar
    Sarah Mei a validé
      describe("initialize", function() {
        it("is called on DOM ready", function() {
    
          spyOn(View, "initialize");
          $(View.initialize);
          expect(View.initialize).toHaveBeenCalled();
        });
    
    Sarah Mei's avatar
    Sarah Mei a validé
      });
    
    
      describe("publisher", function() {
        beforeEach(function() {
          $("#jasmine_content").html(
    
    Sarah Mei's avatar
    Sarah Mei a validé
            '<div id="publisher">' +
              '<form action="/status_messages" class="new_status_message" id="new_status_message" method="post">' +
    
                '<textarea id="status_message_text" name="status_message[text]"></textarea>' +
    
    Sarah Mei's avatar
    Sarah Mei a validé
    
    
      describe("search", function() {
        beforeEach(function() {
          $("#jasmine_content").html(
            '<input id="q" name="q" placeholder="Search" results="5" type="search" class="">'
          );
        });
        describe("focus", function() {
          it("adds the class 'active' when the user focuses the text field", function() {
            View.initialize();
            $(View.search.selector).focus();
            expect($(View.search.selector)).toHaveClass("active");
          });
        });
        describe("blur", function() {
          it("removes the class 'active' when the user blurs the text field", function() {
            View.initialize();
            $(View.search.selector).focus().blur();
            expect($(View.search.selector)).not.toHaveClass("active");
          });
        });
      });
    
      describe("tooltips", function() {
        describe("bindAll", function() {
          //Someone shorten this plz <3
          it("enumerates through the tooltips object, called the method 'bind' on any sibling that is not the bindAll method", function() {
            spyOn($, "noop");
            View.initialize();
            View.tooltips.myToolTip = { bind: $.noop };
            View.tooltips.bindAll();
            expect($.noop).toHaveBeenCalled();
          });
        });
      });
    });