Skip to content

Commit

Permalink
test: fix email-composer test
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoVictor6 committed Nov 30, 2023
1 parent 8a46e28 commit 9de69f0
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from '@faker-js/faker'
import * as sharedFile from 'shared'
import * as createRabbitMqConnectionFile from 'shared/src/queue/createRabbitMqConnection'
import { channelMock } from 'shared/src/test/helpers/rabbitMQ'
import { EmailPreRenderMessage, composeEmail } from 'src/emailComposer'
Expand All @@ -22,6 +23,16 @@ const rabbitMqConfig = () => {
'createRabbitMqConnection'
).mockImplementation(createRabbitMqConnectionStub)
}
const mongoDbConfig = () => {
vi.spyOn(sharedFile, 'getMongoConnection')
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
.mockImplementation(async () => ({
db: () => ({
collection: vi.fn(),
}),
}))
}

describe('Email Composer Service Tests', () => {
beforeEach(() => {
Expand All @@ -32,6 +43,8 @@ describe('Email Composer Service Tests', () => {
})

it('establishes connection with rabbitMQ', async () => {
rabbitMqConfig()
mongoDbConfig()
await composeEmail()
expect(createRabbitMqConnectionStub).toBeCalled()
})
Expand Down

0 comments on commit 9de69f0

Please sign in to comment.