mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-06 08:08:10 +08:00
c952ea3b12
Summary: Eventually, notification stuff should be moved out of InboxAPI into a separate package, and we should have some documented way of watching for "new" things. (Right now it'd be a bit hard to do on the database store...) Additional fixes: - AddRemoveTagsTask now optimistically updates the version. Before it would get the new version from the API response. This was bad because it could still cause local changes to be overwritten if you were changing tags really fast. - AddRemoveTagsTask now takes a threadId, not a thread for consistency with all the rest of our Tasks Test Plan: Run tests Reviewers: evan Reviewed By: evan Differential Revision: https://review.inboxapp.com/D1214
74 lines
2.4 KiB
CoffeeScript
74 lines
2.4 KiB
CoffeeScript
_ = require 'underscore-plus'
|
|
proxyquire = require 'proxyquire'
|
|
Reflux = require 'reflux'
|
|
{Actions} = require 'inbox-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.commands, 'add').andCallThrough()
|
|
@package.activate()
|
|
|
|
args = atom.commands.add.mostRecentCall.args
|
|
expect(args[0]).toEqual('atom-workspace')
|
|
expect(args[1]).toEqual('window:update-available')
|
|
|
|
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(ipcSendArgs).toEqual(0: 'command', 1: 'application:install-update')
|
|
|