From da5d366e49c03f8d8023518ee25783379d2bb75b Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Mon, 2 Jul 2018 15:18:35 -0700 Subject: [PATCH] Added coverage to renderer 'open-about-menu' IPC message --- app/src/renderer/main.js | 2 +- test/unit/specs/App.spec.js | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/app/src/renderer/main.js b/app/src/renderer/main.js index b4ecced0da..b7b3539f8a 100644 --- a/app/src/renderer/main.js +++ b/app/src/renderer/main.js @@ -93,7 +93,7 @@ async function main() { ipcRenderer.send("booted") - new Vue({ + return new Vue({ router, ...App, store diff --git a/test/unit/specs/App.spec.js b/test/unit/specs/App.spec.js index 86da69f835..22306667b9 100644 --- a/test/unit/specs/App.spec.js +++ b/test/unit/specs/App.spec.js @@ -113,6 +113,32 @@ describe("App without analytics", () => { expect(store.state.node.approvalRequired).toBe("THISISSOMEHASH") }) + it("triggers navigation to About on IPC message", async () => { + jest.resetModules() + + let mockPush = jest.fn() + jest.mock( + "vue-router", + () => + function() { + if (this == null) return + this.push = mockPush + } + ) + + const { ipcRenderer } = require("electron") + ipcRenderer.on = (type, cb) => { + if (type === "open-about-menu") { + cb(null) + } + } + + let app = require("renderer/main.js") + expect(mockPush.mock.calls[0][0]).toBe("/preferences") + + jest.resetModules() + }) + it("sends a message to the main thread, that the app has loaded", () => { const { ipcRenderer } = require("electron") ipcRenderer.send = jest.fn()