Switch to white background during export

* Defaulted background option to white for PNG/JPG export

* Attempt at fixing background colour on image output

* Reverted build location change

* WIP for white background

* WIP for white background

* Updating default colour, including saving of existing colour to restore appropriately

* Fix tests and move css change background outside the try block

* keep consistent with american english

* add method to change background color and test wether it has been called with the right params

* change color to original when save fails

Fixes #1422
This commit is contained in:
Deep Tailor
2018-01-16 09:32:49 -08:00
committed by Victor Woeltjen
parent d03f323a9b
commit 9b8d5f3f9c
2 changed files with 42 additions and 8 deletions

View File

@@ -37,7 +37,8 @@ define(
mockFileReader,
mockExportTimeoutConstant,
testElement,
exportImageService;
exportImageService,
mockChangeBackgroundColor;
describe("ExportImageService", function () {
beforeEach(function () {
@@ -83,7 +84,9 @@ define(
["readAsDataURL", "onloadend"]
);
mockExportTimeoutConstant = 0;
testElement = {};
testElement = {style: {backgroundColor: 'black'}};
mockChangeBackgroundColor = jasmine.createSpy('changeBackgroundColor');
exportImageService = new ExportImageService(
mockQ,
@@ -92,7 +95,8 @@ define(
mockExportTimeoutConstant,
mockHtml2Canvas,
mockSaveAs,
mockFileReader
mockFileReader,
mockChangeBackgroundColor
);
});
@@ -115,6 +119,18 @@ define(
expect(mockSaveAs).toHaveBeenCalled();
expect(mockPromise.finally).toHaveBeenCalled();
});
it("changes background color to white and returns color back to original after snapshot, for better visibility of plot lines on print", function () {
exportImageService.exportPNG(testElement, "plot.png");
expect(mockChangeBackgroundColor).toHaveBeenCalledWith(testElement, 'white');
expect(mockChangeBackgroundColor).toHaveBeenCalledWith(testElement, 'black');
exportImageService.exportJPG(testElement, "plot.jpg");
expect(mockChangeBackgroundColor).toHaveBeenCalledWith(testElement, 'white');
expect(mockChangeBackgroundColor).toHaveBeenCalledWith(testElement, 'black');
});
});
}
);