Sha256: c20769bd262bed3ca4c80b674cb24f566613e6204c43e35f2f478dd74c947b50

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

//= require <support/spec_helper>

Screw.Unit(function(c) { with(c) {
  describe("Coolerator.Registrar", function() {
    it("is added to the Coolerator namespace", function() {
      expect(typeof Coolerator.Registrar).to(equal, 'object');
    });

    describe(".subscribe", function() {
      context("pre-document 'ready'", function() {
        before(function() {
          $.isReady = false;
          mock($.fn, 'ready', function(fn) {
            $.readyList = $.readyList || [];
            $.readyList.push(fn);
          });
        });

        after(function() {
          $.isReady   = true;
          $.readyList = null;
          $.fn.ready  = $.fn.ready.original_function;
        });

        it("adds an array of callbacks to jQuery's readyList", function() {
          Coolerator.Registrar.subscribe(this, function() {});
          Coolerator.Registrar.subscribe(this, function() {});
          Coolerator.Registrar.subscribe(this, function() {});

          expect($.readyList).to(have_length, 3);
        });
      });

      context("post-document 'ready", function() {
        var called;

        before(function() {
          called = false;
        });

        it("fires the callback immediately", function() {
          Coolerator.Registrar.subscribe(this, function() {
            called = true;
          });
          expect(called).to(be_true);
        });
      });
    });
  });
}});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
coolerator.vision-0.2.10 spec/javascripts/vendor/coolerator/coolerator.registrar_spec.js