Sha256: 5e7db9bfde32d6b82f5045b48d365aec656c84ad2bda7146e887483cb4166f40

Contents?: true

Size: 1.25 KB

Versions: 8

Compression:

Stored size: 1.25 KB

Contents

describe("Utils",function() {
  describe("fOr",function() {
    it("uses the first function if it's defined",function() {
      // Given
      var called = false;
      var realFunction = function() {
        called = true;
      };
      var otherCalled = false;
      var otherFunction = function() {
        otherCalled = true;
      };

      // When
      Utils.fOr(realFunction,otherFunction)();

      expect(called).toBe(true);
      expect(otherCalled).toBe(false);
    });
    it("uses the other function if the first one is not defined",function() {
      // Given
      var otherCalled = false;
      var otherFunction = function() {
        otherCalled = true;
      };

      // When
      Utils.fOr(undefined,otherFunction)();

      expect(otherCalled).toBe(true);
    });
  });
  describe("f",function() {
    it("uses the real funciton passed",function() {
      // Given
      var returnValue = 42;
      var realFunction = function() {
        return returnValue;
      };

      // When
      var func = Utils.f(realFunction);

      // Then
      expect(func()).toBe(returnValue);
    });

    it("uses a no-op function if none passed",function() {
      // When
      var func = Utils.f();

      // Then
      expect(func()).toBe(undefined);
    });
  });
}); 

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
trickster-1.4.0 test/js/utils_spec.js
trickster-1.3.1 test/js/utils_spec.js
trickster-1.3.0 test/js/utils_spec.js
trickster-1.2.0 test/js/utils_spec.js
trickster-1.1.0 test/js/utils_spec.js
trickster-1.0.0 test/js/utils_spec.js
trickster-0.0.6 test/js/utils_spec.js
trickster-0.0.5 test/js/utils_spec.js