import {ipcRenderer} from 'electron' import InlineStyleTransformer from '../../src/services/inline-style-transformer'; describe("InlineStyleTransformer", function specs() { describe("run", () => { beforeEach(() => { spyOn(ipcRenderer, 'send') spyOn(InlineStyleTransformer, '_injectUserAgentStyles').andCallFake((input) => input); InlineStyleTransformer._inlineStylePromises = {}; }); it("should return a Promise", () => { expect(InlineStyleTransformer.run("asd") instanceof Promise).toBe(true) }); it("should resolve immediately if the html is empty", async () => { const promise = InlineStyleTransformer.run("") expect(await promise.isResolved()).toBe(true) }); it("should resolve immediately if there is no `) expect(ipcRenderer.send.mostRecentCall.args[1].html).toEqual(` `) }); it("should add user agent styles", () => { InlineStyleTransformer.run(`Other content goes here`) expect(InlineStyleTransformer._injectUserAgentStyles).toHaveBeenCalled() }); it("should fire inline-style-parse to the main process", () => { InlineStyleTransformer.run(`Other content goes here`) expect(ipcRenderer.send).toHaveBeenCalled() expect(ipcRenderer.send.mostRecentCall.args[0]).toEqual('inline-style-parse'); }); }); });