{:uriI"file:///Users/izik/www/sparse/izi_lightup/spec/javascripts/crit-utils/wait_for_spec.js?type=application/javascript&pipeline=self&id=ebae9316de08599bcd5c6c5bc752b4e062b07ea839ca11c84f990291b0c9795c:ET:load_pathI"8/Users/izik/www/sparse/izi_lightup/spec/javascripts;T: filenameI"T/Users/izik/www/sparse/izi_lightup/spec/javascripts/crit-utils/wait_for_spec.js;T: nameI"crit-utils/wait_for_spec;T:logical_pathI"%crit-utils/wait_for_spec.self.js;T:content_typeI"application/javascript;T: sourceI" describe("waitFor", function () { var $clock; beforeEach(function () { $clock = jasmine.clock(); waitFor.tick = 1; waitFor.timeout = 100; }); it("should exists as global function", function () { expect(waitFor).toBeDefined(); expect(typeof waitFor).toBe("function"); }); describe("callbacks", function () { it("should return curried fn to pass callback", function () { expect(typeof waitFor("SOMEWHAT")).toBe("function"); }); it("should call success callback", function () { return new Promise(function (resolve) { waitFor("jQuery")(function () { expect(jQuery).toBeDefined(); resolve(); }); }); }); it("should wait for required global variable", function () { $clock.install(); return new Promise(function (resolve) { var KEY = "key" + Math.random(); expect(window[KEY]).toBeUndefined(); $clock.tick(500); setTimeout(function () { window[KEY] = "TODO"; }, 500); $clock.tick(500); waitFor(KEY)(function () { expect(window[KEY]).toBeDefined(); $clock.uninstall(); resolve(); }); }); }); it("should call fail callback by timeout", function () { waitFor.tick = 1; waitFor.timeout = 10; return new Promise(function (resolve) { var KEY = "key" + Math.random(); expect(window[KEY]).toBeUndefined(); waitFor(KEY)(function () { expect("Should not be called").toBe(""); resolve(); }, function (message) { expect(window[KEY]).toBeUndefined(); expect(message).toContain("not loaded component"); resolve(); }); }); }); it("should not call success callback if already failed", function () { waitFor.tick = 1; waitFor.timeout = 10; return new Promise(function (resolve) { var KEY = "key" + Math.random(); expect(window[KEY]).toBeUndefined(); waitFor(KEY)(function () { expect("Should not be called").toBe(""); resolve(); }, function () { window[KEY] = true; setTimeout(resolve, 50); }); }); }); }); describe("property: deepCheck", function () { it("should allow to pass second prop for deep check", function () { var KEY = "key" + Math.random(); var called = false; return new Promise(function (resolve, reject) { waitFor(KEY, function() { return called = true; })(function () { expect(called).toBeTruthy(); resolve(); }, reject); }); }); }); describe("property: interval", function () {}); }); ;T: metadata{ :dependencieso:Set: @hash} I"environment-version;TTI"environment-paths;TTI"rails-env;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"bfile-digest:///Users/izik/www/sparse/izi_lightup/spec/javascripts/crit-utils/wait_for_spec.js;TTF: requiredo;;}F: stubbedo;;}F: linkso;;}F: charsetI" utf-8;F: digest"% BeR𐗮=0>Ib .4_w: lengthi :dependencies_digest"%օ5Z9:vYra9:idI"Eebae9316de08599bcd5c6c5bc752b4e062b07ea839ca11c84f990291b0c9795c;F: mtimel+@]b