TriggerTransitionFromPrimaryToSecondaryDatabaseForUser.spec.ts 1.1 KB

123456789101112131415161718192021222324252627282930
  1. import { DomainEventPublisherInterface } from '@standardnotes/domain-events'
  2. import { TriggerTransitionFromPrimaryToSecondaryDatabaseForUser } from './TriggerTransitionFromPrimaryToSecondaryDatabaseForUser'
  3. import { DomainEventFactoryInterface } from '../../../Event/DomainEventFactoryInterface'
  4. describe('TriggerTransitionFromPrimaryToSecondaryDatabaseForUser', () => {
  5. let domainEventPubliser: DomainEventPublisherInterface
  6. let domainEventFactory: DomainEventFactoryInterface
  7. const createUseCase = () =>
  8. new TriggerTransitionFromPrimaryToSecondaryDatabaseForUser(domainEventPubliser, domainEventFactory)
  9. beforeEach(() => {
  10. domainEventPubliser = {} as jest.Mocked<DomainEventPublisherInterface>
  11. domainEventPubliser.publish = jest.fn()
  12. domainEventFactory = {} as jest.Mocked<DomainEventFactoryInterface>
  13. domainEventFactory.createTransitionStatusUpdatedEvent = jest.fn()
  14. })
  15. it('should publish transition status updated event', async () => {
  16. const useCase = createUseCase()
  17. await useCase.execute({
  18. userUuid: '00000000-0000-0000-0000-000000000000',
  19. })
  20. expect(domainEventPubliser.publish).toHaveBeenCalled()
  21. })
  22. })