mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-20 22:23:53 +08:00
fix(unread-notifications): Fix failing tests, add one for "Unknown" sender
This commit is contained in:
parent
b78aaf432a
commit
730ba06c47
2 changed files with 14 additions and 1 deletions
|
@ -46,7 +46,7 @@ module.exports =
|
|||
body = msg.subject
|
||||
if not body or body.length is 0
|
||||
body = msg.snippet
|
||||
from = msg.from[0]?.displayName ? "Unknown"
|
||||
from = msg.from[0]?.displayName() ? "Unknown"
|
||||
notif = new Notification(from, {
|
||||
body: body
|
||||
tag: 'unread-update'
|
||||
|
|
|
@ -21,6 +21,12 @@ describe "UnreadNotifications", ->
|
|||
from: [new Contact(name: 'Ben', email: 'ben@example.com')]
|
||||
subject: "Hello World"
|
||||
threadId: "A"
|
||||
@msgNoSender = new Message
|
||||
unread: true
|
||||
date: new Date()
|
||||
from: []
|
||||
subject: "Hello World"
|
||||
threadId: "A"
|
||||
@msg2 = new Message
|
||||
unread: true
|
||||
date: new Date()
|
||||
|
@ -78,6 +84,13 @@ describe "UnreadNotifications", ->
|
|||
expect(window.Notification).toHaveBeenCalled()
|
||||
expect(window.Notification.mostRecentCall.args).toEqual([ '2 Unread Messages', { tag : 'unread-update' } ])
|
||||
|
||||
it "should create a Notification correctly, even if new mail has no sender", ->
|
||||
waitsForPromise =>
|
||||
Main._onNewMailReceived({message: [@msgNoSender]})
|
||||
.then ->
|
||||
expect(window.Notification).toHaveBeenCalled()
|
||||
expect(window.Notification.mostRecentCall.args).toEqual([ 'Unknown', { body : 'Hello World', tag : 'unread-update' } ])
|
||||
|
||||
it "should not create a Notification if there are no new messages", ->
|
||||
waitsForPromise ->
|
||||
Main._onNewMailReceived({message: []})
|
||||
|
|
Loading…
Reference in a new issue