{I" class:EFI"BundledAsset;FI"logical_path;FI""teaspoon/base/fixture_spec.js;TI" pathname;FI"Z/Users/jejacks0n/Projects/teaspoon/spec/javascripts/teaspoon/base/fixture_spec.coffee;FI"content_type;FI"application/javascript;FI" mtime;Fl+Qú½QI" length;FieI" digest;F"%0a95a5f9cf0a8f648bf7cf20b4ccdef0I" source;FI"e(function() { describe("Teaspoon.fixture", function() { beforeEach(function() { var e; fixture.cache = {}; fixture.cleanup(); this.mockXhr = { readyState: 4, status: 200, responseText: "_content_", getResponseHeader: function() { return "_type_"; }, open: function() {}, send: function() {} }; this.xhrSpy = spyOn(this.mockXhr, 'open'); this.xhrSpy; try { return spyOn(window, 'XMLHttpRequest').andReturn(this.mockXhr); } catch (_error) { e = _error; return spyOn(window, 'ActiveXObject').andReturn(this.mockXhr); } }); describe("@load", function() { it("loads all of the files requested", function() { fixture.load("fixture.html", "fixture.json"); expect(this.xhrSpy).toHaveBeenCalledWith("GET", "/teaspoon/fixtures/fixture.html", false); return expect(this.xhrSpy).toHaveBeenCalledWith("GET", "/teaspoon/fixtures/fixture.json", false); }); it("caches the type/contents of those files", function() { fixture.load("fixture.html"); this.mockXhr.onreadystatechange(); return expect(fixture.cache["fixture.html"]).toEqual({ type: "_type_", content: "_content_" }); }); it("throws an exception if unable to load a file", function() { var _this = this; fixture.load("foo.html"); this.mockXhr.status = 500; return expect(function() { return _this.mockXhr.onreadystatechange(); }).toThrow("Unable to load fixture \"foo.html\"."); }); it("adds the contents of files to a fixture element", function() { fixture.load("fixture.html"); this.mockXhr.onreadystatechange(); expect(document.getElementById("teaspoon-fixtures").tagName).toBe("DIV"); expect(document.getElementById("teaspoon-fixtures").innerHTML).toBe("_content_"); return expect(document.getElementById("teaspoon-fixtures")).toBe(fixture.el); }); it("allows appending file contents to the fixture element", function() { fixture.load("fixture.html1"); this.mockXhr.onreadystatechange(); expect(document.getElementById("teaspoon-fixtures").tagName).toBe("DIV"); expect(document.getElementById("teaspoon-fixtures").innerHTML).toBe("_content_"); fixture.load("fixture.html2", true); this.mockXhr.onreadystatechange(); expect(document.getElementById("teaspoon-fixtures").innerHTML).toBe("_content__content_"); fixture.load("fixture.html3", false); this.mockXhr.onreadystatechange(); return expect(document.getElementById("teaspoon-fixtures").innerHTML).toBe("_content_"); }); return it("handles JSON fixtures", function() { this.mockXhr.responseText = '{"foo": "bar"}'; this.mockXhr.getResponseHeader = function() { return "application/json; encoding-blah"; }; fixture.load("fixture.json"); this.mockXhr.onreadystatechange(); expect(fixture.json.length).toBe(1); return expect(fixture.json[0]).toEqual({ foo: "bar" }); }); }); describe("@set", function() { it("adds all the contents passed to a fixture element", function() { fixture.set("_content1_", "_content2_"); expect(document.getElementById("teaspoon-fixtures").tagName).toBe("DIV"); return expect(document.getElementById("teaspoon-fixtures").innerHTML).toBe("_content1__content2_"); }); return it("allows appending contents to the fixture element", function() { fixture.set("_content1_"); expect(document.getElementById("teaspoon-fixtures").tagName).toBe("DIV"); expect(document.getElementById("teaspoon-fixtures").innerHTML).toBe("_content1_"); fixture.set("_content2_", true); expect(document.getElementById("teaspoon-fixtures").innerHTML).toBe("_content1__content2_"); fixture.set("_content3_", false); return expect(document.getElementById("teaspoon-fixtures").innerHTML).toBe("_content3_"); }); }); return describe("@preload", function() { it("loads all of the files requested", function() { fixture.preload("fixture.html", "fixture.json"); expect(this.xhrSpy).toHaveBeenCalledWith("GET", "/teaspoon/fixtures/fixture.html", false); return expect(this.xhrSpy).toHaveBeenCalledWith("GET", "/teaspoon/fixtures/fixture.json", false); }); expect(document.getElementById("teaspoon-fixtures")).toBe(null); return it("caches the type/contents of those files", function() { fixture.preload("fixture.html"); this.mockXhr.onreadystatechange(); return expect(fixture.cache["fixture.html"]).toEqual({ type: "_type_", content: "_content_" }); }); }); }); }).call(this); ;TI"required_assets_digest;F"%a92d5dcba5ad38d71720272711d89f25I" _version;F"%f9a10b06158d64a75654a1ef72ec0ff4