@cypress/core-desktop-gui
Version:
Desktop GUI for managing Cypress projects.
67 lines (53 loc) • 1.78 kB
text/coffeescript
describe "App", ->
beforeEach ->
cy
.visit("/")
.window().then (win) ->
{, } = win
= cy.agents()
.spy(, "ipc")
.handle("get:options", null, {})
context "window.onerror", ->
it "attaches to window.onerror", ->
cy.window().then (win) ->
cy.wrap(win.onerror).should("be.a", "function")
it "attaches to window.onunhandledrejection", ->
cy.window().then (win) ->
cy.wrap(win.onunhandledrejection).should("be.a", "function")
it "sends name, stack, message to gui:error on synchronous error", ->
err = new Error("foo")
cy.window().then (win) ->
win.onerror(1, 2, 3, 4, err)
expect(.ipc).to.be.calledWithExactly("gui:error", {
name: "Error"
message: "foo"
stack: err.stack
})
it "sends name, stack, message to gui:error on unhandled rejection", ->
err = new Error("foo")
cy.window().then (win) ->
win.foo = ->
new win.Promise (resolve, reject) ->
reject(err)
setTimeout ->
win.foo()
, 0
.wrap(.ipc).should("be.calledWithExactly", "gui:error", {
name: "Error"
message: "foo"
stack: err.stack
})
context "on:menu:clicked", ->
it "calls log:out", ->
.handle("on:menu:clicked", null, "log:out")
expect(.ipc).to.be.calledWith("log:out")
it "checks for updates", ->
.handle("on:menu:clicked", null, 'check:for:updates')
expect(.ipc).to.be.calledWithExactly("window:open", {
position: "center",
width: 300,
height: 210,
toolbar: false,
title: "Updates",
type: "UPDATES",
})