Skip to content

Commit

Permalink
Added coverage to renderer 'open-about-menu' IPC message
Browse files Browse the repository at this point in the history
  • Loading branch information
mappum committed Jul 2, 2018
1 parent b9aeb17 commit da5d366
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/src/renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async function main() {

ipcRenderer.send("booted")

new Vue({
return new Vue({
router,
...App,
store
Expand Down
26 changes: 26 additions & 0 deletions test/unit/specs/App.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit da5d366

Please sign in to comment.