mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-08 17:17:56 +08:00
38 lines
1.1 KiB
Text
38 lines
1.1 KiB
Text
|
import {
|
||
|
Actions,
|
||
|
Message,
|
||
|
DraftHelpers,
|
||
|
SyncbackDraftFilesTask,
|
||
|
} from 'nylas-exports';
|
||
|
|
||
|
describe('DraftHelpers', function describeBlock() {
|
||
|
describe('prepareForSyncback', () => {
|
||
|
beforeEach(() => {
|
||
|
spyOn(DraftHelpers, 'applyExtensionTransformsToDraft').andCallFake((draft) => Promise.resolve(draft))
|
||
|
spyOn(Actions, 'queueTask')
|
||
|
});
|
||
|
|
||
|
it('queues tasks to upload files and send the draft', () => {
|
||
|
const draft = new Message({
|
||
|
clientId: "local-123",
|
||
|
threadId: "thread-123",
|
||
|
replyToMessageId: "message-123",
|
||
|
uploads: ['stub'],
|
||
|
});
|
||
|
const session = {
|
||
|
ensureCorrectAccount() { return Promise.resolve() },
|
||
|
draft() { return draft },
|
||
|
}
|
||
|
runs(() => {
|
||
|
DraftHelpers.prepareDraftForSyncback(session);
|
||
|
});
|
||
|
waitsFor(() => Actions.queueTask.calls.length > 0);
|
||
|
runs(() => {
|
||
|
const saveAttachments = Actions.queueTask.calls[0].args[0];
|
||
|
expect(saveAttachments instanceof SyncbackDraftFilesTask).toBe(true);
|
||
|
expect(saveAttachments.draftClientId).toBe(draft.clientId);
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
});
|