mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-11 10:12:00 +08:00
fc4b3b56d7
Summary: Fixes: T1334 remove final InboxApp references move out all underscore-plus methods Mass find and replace of underscore-plus sed -i '' -- 's/underscore-plus/underscore/g' **/*.coffee sed -i '' -- 's/underscore-plus/underscore/g' **/*.cjsx Test Plan: edgehill --test Reviewers: bengotow Reviewed By: bengotow Differential Revision: https://phab.nylas.com/D1534
71 lines
2.3 KiB
CoffeeScript
71 lines
2.3 KiB
CoffeeScript
_ = require 'underscore'
|
|
proxyquire = require 'proxyquire'
|
|
Reflux = require 'reflux'
|
|
{Actions} = require 'nylas-exports'
|
|
|
|
stubUpdaterState = null
|
|
stubUpdaterReleaseVersion = null
|
|
ipcSendArgs = null
|
|
|
|
PackageMain = proxyquire "../lib/main",
|
|
"ipc":
|
|
send: ->
|
|
ipcSendArgs = arguments
|
|
"remote":
|
|
getGlobal: (global) ->
|
|
autoUpdateManager:
|
|
releaseVersion: stubUpdaterReleaseVersion
|
|
getState: -> stubUpdaterState
|
|
|
|
describe "NotificationUpdateAvailable", ->
|
|
beforeEach ->
|
|
stubUpdaterState = 'idle'
|
|
stubUpdaterReleaseVersion = undefined
|
|
ipcSendArgs = null
|
|
@package = PackageMain
|
|
|
|
afterEach ->
|
|
@package.deactivate()
|
|
|
|
describe "activate", ->
|
|
it "should display a notification immediately if one is available", ->
|
|
spyOn(@package, 'displayNotification')
|
|
stubUpdaterState = 'update-available'
|
|
@package.activate()
|
|
expect(@package.displayNotification).toHaveBeenCalled()
|
|
|
|
it "should not display a notification if no update is avialable", ->
|
|
spyOn(@package, 'displayNotification')
|
|
stubUpdaterState = 'no-update-available'
|
|
@package.activate()
|
|
expect(@package.displayNotification).not.toHaveBeenCalled()
|
|
|
|
it "should listen for `window:update-available`", ->
|
|
spyOn(atom, 'onUpdateAvailable').andCallThrough()
|
|
@package.activate()
|
|
expect(atom.onUpdateAvailable).toHaveBeenCalled()
|
|
|
|
describe "displayNotification", ->
|
|
beforeEach ->
|
|
@package.activate()
|
|
|
|
it "should fire a postNotification Action", ->
|
|
spyOn(Actions, 'postNotification')
|
|
@package.displayNotification()
|
|
expect(Actions.postNotification).toHaveBeenCalled()
|
|
|
|
it "should include the version if one is provided", ->
|
|
spyOn(Actions, 'postNotification')
|
|
|
|
version = '0.515.0-123123'
|
|
@package.displayNotification(version)
|
|
expect(Actions.postNotification).toHaveBeenCalled()
|
|
|
|
notifOptions = Actions.postNotification.mostRecentCall.args[0]
|
|
expect(notifOptions.message.indexOf(version) > 0).toBe(true)
|
|
|
|
describe "when the action is taken", ->
|
|
it "should fire the `application:install-update` IPC event", ->
|
|
Actions.notificationActionTaken({notification: {}, action: {id: 'release-bar:install-update'}})
|
|
expect(Array.prototype.slice.call(ipcSendArgs)).toEqual(['command', 'application:install-update'])
|
|
|