|
@@ -3,7 +3,7 @@ import 'reflect-metadata'
|
|
import {
|
|
import {
|
|
DomainEventPublisherInterface,
|
|
DomainEventPublisherInterface,
|
|
EmailArchiveExtensionSyncedEvent,
|
|
EmailArchiveExtensionSyncedEvent,
|
|
- EmailBackupAttachmentCreatedEvent,
|
|
|
|
|
|
+ EmailRequestedEvent,
|
|
} from '@standardnotes/domain-events'
|
|
} from '@standardnotes/domain-events'
|
|
import { Logger } from 'winston'
|
|
import { Logger } from 'winston'
|
|
import { AuthHttpServiceInterface } from '../Auth/AuthHttpServiceInterface'
|
|
import { AuthHttpServiceInterface } from '../Auth/AuthHttpServiceInterface'
|
|
@@ -35,6 +35,7 @@ describe('EmailArchiveExtensionSyncedEventHandler', () => {
|
|
domainEventFactory,
|
|
domainEventFactory,
|
|
emailAttachmentMaxByteSize,
|
|
emailAttachmentMaxByteSize,
|
|
itemTransferCalculator,
|
|
itemTransferCalculator,
|
|
|
|
+ 's3-backup-bucket-name',
|
|
logger,
|
|
logger,
|
|
)
|
|
)
|
|
|
|
|
|
@@ -62,9 +63,7 @@ describe('EmailArchiveExtensionSyncedEventHandler', () => {
|
|
domainEventPublisher.publish = jest.fn()
|
|
domainEventPublisher.publish = jest.fn()
|
|
|
|
|
|
domainEventFactory = {} as jest.Mocked<DomainEventFactoryInterface>
|
|
domainEventFactory = {} as jest.Mocked<DomainEventFactoryInterface>
|
|
- domainEventFactory.createEmailBackupAttachmentCreatedEvent = jest
|
|
|
|
- .fn()
|
|
|
|
- .mockReturnValue({} as jest.Mocked<EmailBackupAttachmentCreatedEvent>)
|
|
|
|
|
|
+ domainEventFactory.createEmailRequestedEvent = jest.fn().mockReturnValue({} as jest.Mocked<EmailRequestedEvent>)
|
|
|
|
|
|
itemTransferCalculator = {} as jest.Mocked<ItemTransferCalculatorInterface>
|
|
itemTransferCalculator = {} as jest.Mocked<ItemTransferCalculatorInterface>
|
|
itemTransferCalculator.computeItemUuidBundlesToFetch = jest.fn().mockReturnValue([['1-2-3']])
|
|
itemTransferCalculator.computeItemUuidBundlesToFetch = jest.fn().mockReturnValue([['1-2-3']])
|
|
@@ -78,12 +77,7 @@ describe('EmailArchiveExtensionSyncedEventHandler', () => {
|
|
await createHandler().handle(event)
|
|
await createHandler().handle(event)
|
|
|
|
|
|
expect(domainEventPublisher.publish).toHaveBeenCalledTimes(1)
|
|
expect(domainEventPublisher.publish).toHaveBeenCalledTimes(1)
|
|
- expect(domainEventFactory.createEmailBackupAttachmentCreatedEvent).toHaveBeenCalledWith({
|
|
|
|
- backupFileIndex: 1,
|
|
|
|
- backupFileName: 'backup-file-name',
|
|
|
|
- backupFilesTotal: 1,
|
|
|
|
- email: 'test@test.com',
|
|
|
|
- })
|
|
|
|
|
|
+ expect(domainEventFactory.createEmailRequestedEvent).toHaveBeenCalled()
|
|
})
|
|
})
|
|
|
|
|
|
it('should inform that multipart backup attachment for email was created', async () => {
|
|
it('should inform that multipart backup attachment for email was created', async () => {
|
|
@@ -96,18 +90,7 @@ describe('EmailArchiveExtensionSyncedEventHandler', () => {
|
|
await createHandler().handle(event)
|
|
await createHandler().handle(event)
|
|
|
|
|
|
expect(domainEventPublisher.publish).toHaveBeenCalledTimes(2)
|
|
expect(domainEventPublisher.publish).toHaveBeenCalledTimes(2)
|
|
- expect(domainEventFactory.createEmailBackupAttachmentCreatedEvent).toHaveBeenNthCalledWith(1, {
|
|
|
|
- backupFileIndex: 1,
|
|
|
|
- backupFileName: 'backup-file-name-1',
|
|
|
|
- backupFilesTotal: 2,
|
|
|
|
- email: 'test@test.com',
|
|
|
|
- })
|
|
|
|
- expect(domainEventFactory.createEmailBackupAttachmentCreatedEvent).toHaveBeenNthCalledWith(2, {
|
|
|
|
- backupFileIndex: 2,
|
|
|
|
- backupFileName: 'backup-file-name-2',
|
|
|
|
- backupFilesTotal: 2,
|
|
|
|
- email: 'test@test.com',
|
|
|
|
- })
|
|
|
|
|
|
+ expect(domainEventFactory.createEmailRequestedEvent).toHaveBeenCalledTimes(2)
|
|
})
|
|
})
|
|
|
|
|
|
it('should not inform that backup attachment for email was created if user key params cannot be obtained', async () => {
|
|
it('should not inform that backup attachment for email was created if user key params cannot be obtained', async () => {
|
|
@@ -118,7 +101,7 @@ describe('EmailArchiveExtensionSyncedEventHandler', () => {
|
|
await createHandler().handle(event)
|
|
await createHandler().handle(event)
|
|
|
|
|
|
expect(domainEventPublisher.publish).not.toHaveBeenCalled()
|
|
expect(domainEventPublisher.publish).not.toHaveBeenCalled()
|
|
- expect(domainEventFactory.createEmailBackupAttachmentCreatedEvent).not.toHaveBeenCalled()
|
|
|
|
|
|
+ expect(domainEventFactory.createEmailRequestedEvent).not.toHaveBeenCalled()
|
|
})
|
|
})
|
|
|
|
|
|
it('should not inform that backup attachment for email was created if backup file name is empty', async () => {
|
|
it('should not inform that backup attachment for email was created if backup file name is empty', async () => {
|
|
@@ -127,6 +110,6 @@ describe('EmailArchiveExtensionSyncedEventHandler', () => {
|
|
await createHandler().handle(event)
|
|
await createHandler().handle(event)
|
|
|
|
|
|
expect(domainEventPublisher.publish).not.toHaveBeenCalled()
|
|
expect(domainEventPublisher.publish).not.toHaveBeenCalled()
|
|
- expect(domainEventFactory.createEmailBackupAttachmentCreatedEvent).not.toHaveBeenCalled()
|
|
|
|
|
|
+ expect(domainEventFactory.createEmailRequestedEvent).not.toHaveBeenCalled()
|
|
})
|
|
})
|
|
})
|
|
})
|