mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-23 15:46:28 +08:00
fix(draft): fix forwarding message with files and add spec
This commit is contained in:
parent
b61cdc6f32
commit
bdccbfa517
2 changed files with 27 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
|||
File = require '../../src/flux/models/file'
|
||||
Thread = require '../../src/flux/models/thread'
|
||||
Message = require '../../src/flux/models/message'
|
||||
Contact = require '../../src/flux/models/contact'
|
||||
|
@ -21,6 +22,7 @@ msgWithReplyTo = null
|
|||
msgWithReplyToDuplicates = null
|
||||
messageWithStyleTags = null
|
||||
fakeMessages = null
|
||||
fakeMessageWithFiles = null
|
||||
|
||||
class TestExtension extends DraftStoreExtension
|
||||
@prepareNewDraft: (draft) ->
|
||||
|
@ -68,6 +70,18 @@ describe "DraftStore", ->
|
|||
subject: 'Re: Fake Subject'
|
||||
date: new Date(1415814587)
|
||||
|
||||
fakeMessageWithFiles = new Message
|
||||
id: 'fake-message-with-files'
|
||||
to: [new Contact(email: 'ben@nylas.com'), new Contact(email: 'evan@nylas.com')]
|
||||
cc: [new Contact(email: 'mg@nylas.com'), new Contact(email: AccountStore.current().me().email)]
|
||||
bcc: [new Contact(email: 'recruiting@nylas.com')]
|
||||
from: [new Contact(email: 'customer@example.com', name: 'Customer')]
|
||||
files: [new File(filename: "test.jpg"), new File(filename: "test.pdj")]
|
||||
threadId: 'fake-thread-id'
|
||||
body: 'Fake Message 1'
|
||||
subject: 'Fake Subject'
|
||||
date: new Date(1415814587)
|
||||
|
||||
msgFromMe = new Message
|
||||
id: 'fake-message-3'
|
||||
to: [new Contact(email: '1@1.com'), new Contact(email: '2@2.com')]
|
||||
|
@ -118,6 +132,7 @@ describe "DraftStore", ->
|
|||
'fake-message-3': msgFromMe
|
||||
'fake-message-2': fakeMessage2
|
||||
'fake-message-reply-to': msgWithReplyTo
|
||||
'fake-message-with-files': fakeMessageWithFiles
|
||||
'fake-message-reply-to-duplicates': msgWithReplyToDuplicates
|
||||
'message-with-style-tags': messageWithStyleTags
|
||||
|
||||
|
@ -275,6 +290,17 @@ describe "DraftStore", ->
|
|||
expect(@model.cc).toEqual(msgFromMe.cc)
|
||||
expect(@model.bcc.length).toBe 0
|
||||
|
||||
describe "forwarding with attachments", ->
|
||||
it "should include the attached files", ->
|
||||
runs ->
|
||||
DraftStore._onComposeForward({threadId: fakeThread.id, messageId: fakeMessageWithFiles.id})
|
||||
waitsFor ->
|
||||
DatabaseStore.persistModel.callCount > 0
|
||||
runs ->
|
||||
@model = DatabaseStore.persistModel.mostRecentCall.args[0]
|
||||
expect(@model.files.length).toBe 2
|
||||
expect(@model.files[0].filename).toBe "test.jpg"
|
||||
|
||||
describe "onComposeForward", ->
|
||||
beforeEach ->
|
||||
runs ->
|
||||
|
|
|
@ -291,7 +291,7 @@ class DraftStore
|
|||
|
||||
if msg.files?.length > 0
|
||||
attributes.files ?= []
|
||||
attributes.files = attributes.files.concat(forwardMessage.files)
|
||||
attributes.files = attributes.files.concat(msg.files)
|
||||
|
||||
attributes.subject = subjectWithPrefix(msg.subject, 'Fwd:')
|
||||
delete attributes.forwardedMessage
|
||||
|
|
Loading…
Reference in a new issue