mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-07 23:59:22 +03:00
0b44cee8db
Path opening and update signaling were both using the command-sending IPC mechanism, but neither is actually a command. This commit adds a second “message” channel with custom handling on the render process side for these messages, rather than attempting to route them through commands.
127 lines
4.1 KiB
CoffeeScript
127 lines
4.1 KiB
CoffeeScript
{$, $$} = require '../src/space-pen-extensions'
|
|
Exec = require('child_process').exec
|
|
path = require 'path'
|
|
Package = require '../src/package'
|
|
ThemeManager = require '../src/theme-manager'
|
|
|
|
describe "the `atom` global", ->
|
|
describe 'window sizing methods', ->
|
|
describe '::getPosition and ::setPosition', ->
|
|
it 'sets the position of the window, and can retrieve the position just set', ->
|
|
atom.setPosition(22, 45)
|
|
expect(atom.getPosition()).toEqual x: 22, y: 45
|
|
|
|
describe '::getSize and ::setSize', ->
|
|
originalSize = null
|
|
beforeEach ->
|
|
originalSize = atom.getSize()
|
|
afterEach ->
|
|
atom.setSize(originalSize.width, originalSize.height)
|
|
|
|
it 'sets the size of the window, and can retrieve the size just set', ->
|
|
atom.setSize(100, 400)
|
|
expect(atom.getSize()).toEqual width: 100, height: 400
|
|
|
|
describe ".isReleasedVersion()", ->
|
|
it "returns false if the version is a SHA and true otherwise", ->
|
|
version = '0.1.0'
|
|
spyOn(atom, 'getVersion').andCallFake -> version
|
|
expect(atom.isReleasedVersion()).toBe true
|
|
version = '36b5518'
|
|
expect(atom.isReleasedVersion()).toBe false
|
|
|
|
describe "when an update becomes available", ->
|
|
subscription = null
|
|
|
|
afterEach ->
|
|
subscription?.dispose()
|
|
|
|
it "invokes onUpdateAvailable listeners", ->
|
|
updateAvailableHandler = jasmine.createSpy("update-available-handler")
|
|
subscription = atom.onUpdateAvailable updateAvailableHandler
|
|
|
|
autoUpdater = require('remote').require('auto-updater')
|
|
autoUpdater.emit 'update-downloaded', null, "notes", "version"
|
|
|
|
waitsFor ->
|
|
updateAvailableHandler.callCount > 0
|
|
|
|
runs ->
|
|
{releaseVersion, releaseNotes} = updateAvailableHandler.mostRecentCall.args[0]
|
|
expect(releaseVersion).toBe 'version'
|
|
expect(releaseNotes).toBe 'notes'
|
|
|
|
describe "loading default config", ->
|
|
it 'loads the default core config', ->
|
|
expect(atom.config.get('core.excludeVcsIgnoredPaths')).toBe true
|
|
expect(atom.config.get('editor.showInvisibles')).toBe false
|
|
|
|
describe "window onerror handler", ->
|
|
beforeEach ->
|
|
spyOn atom, 'openDevTools'
|
|
spyOn atom, 'executeJavaScriptInDevTools'
|
|
|
|
it "will open the dev tools when an error is triggered", ->
|
|
try
|
|
a + 1
|
|
catch e
|
|
window.onerror.call(window, e.toString(), 'abc', 2, 3, e)
|
|
|
|
expect(atom.openDevTools).toHaveBeenCalled()
|
|
expect(atom.executeJavaScriptInDevTools).toHaveBeenCalled()
|
|
|
|
describe "::onWillThrowError", ->
|
|
willThrowSpy = null
|
|
beforeEach ->
|
|
willThrowSpy = jasmine.createSpy()
|
|
|
|
it "is called when there is an error", ->
|
|
error = null
|
|
atom.onWillThrowError(willThrowSpy)
|
|
try
|
|
a + 1
|
|
catch e
|
|
error = e
|
|
window.onerror.call(window, e.toString(), 'abc', 2, 3, e)
|
|
|
|
delete willThrowSpy.mostRecentCall.args[0].preventDefault
|
|
expect(willThrowSpy).toHaveBeenCalledWith
|
|
message: error.toString()
|
|
url: 'abc'
|
|
line: 2
|
|
column: 3
|
|
originalError: error
|
|
|
|
it "will not show the devtools when preventDefault() is called", ->
|
|
willThrowSpy.andCallFake (errorObject) -> errorObject.preventDefault()
|
|
atom.onWillThrowError(willThrowSpy)
|
|
|
|
try
|
|
a + 1
|
|
catch e
|
|
window.onerror.call(window, e.toString(), 'abc', 2, 3, e)
|
|
|
|
expect(willThrowSpy).toHaveBeenCalled()
|
|
expect(atom.openDevTools).not.toHaveBeenCalled()
|
|
expect(atom.executeJavaScriptInDevTools).not.toHaveBeenCalled()
|
|
|
|
describe "::onDidThrowError", ->
|
|
didThrowSpy = null
|
|
beforeEach ->
|
|
didThrowSpy = jasmine.createSpy()
|
|
|
|
it "is called when there is an error", ->
|
|
error = null
|
|
atom.onDidThrowError(didThrowSpy)
|
|
try
|
|
a + 1
|
|
catch e
|
|
error = e
|
|
window.onerror.call(window, e.toString(), 'abc', 2, 3, e)
|
|
expect(didThrowSpy).toHaveBeenCalledWith
|
|
message: error.toString()
|
|
url: 'abc'
|
|
line: 2
|
|
column: 3
|
|
originalError: error
|