describe("Integration test", function () { "use strict"; var canvas, // eslint-disable-next-line no-unused-vars finished, // eslint-disable-next-line no-unused-vars callback, referenceImg, width = 200, height = 100; var forceImageSizeForPlatformCompatibility = function (image) { image.width = width; image.height = height; }; var createElementFrom = function (htmlString) { var div = document.createElement("div"); div.innerHTML = htmlString; return div.childNodes[0]; }; beforeEach(function () { jasmine.addMatchers(diffHelper.matcher); jasmine.addMatchers(imagediff.jasmine); canvas = createElementFrom( '', ); // Firefox adds a space between the divs and needs the canvas to fit horizontally for all content to be rendered referenceImg = createElementFrom( 'test image', ); finished = false; callback = jasmine.createSpy("callback").and.callFake(function () { finished = true; }); }); it("should take a document, inline all displayable content and render to the given canvas", function (done) { testHelper.readHTMLDocumentFixture("test.html").then(function (doc) { rasterizeHTML .drawDocument(doc, canvas, { cache: "none", baseUrl: testHelper.fixturesPath, // we need this because of workAroundFirefoxNotLoadingStylesheetStyles() active: ".bgimage", hover: ".webfont", clip: "body", }) .then(function (result) { expect(result.errors).toEqual([]); expect(result.svg).toMatch(/", { cache: "none" }) .then(null, function (error) { expect(error.message).toEqual("Invalid source"); }) .catch(function (err) { expect(err).toBe(null); fail(); }) .finally(done); }); it("should report a source error on invalid input from URL", function (done) { rasterizeHTML .drawURL(testHelper.fixturesPath + "invalidInput.html", { cache: "none", }) .then(null, function (error) { expect(error.message).toEqual("Invalid source"); }) .catch(function (err) { expect(err).toBe(null); fail(); }) .finally(done); }); });