Skip to content

Commit

Permalink
🧪 chore: fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rezk2ll committed Jan 7, 2025
1 parent cb96ca3 commit c9699b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ app.use(
)
)

beforeEach(() => {
jest.resetAllMocks()
})

describe('the invitation API controller', () => {
describe('the sendInvitation method', () => {
it('should try to send an invitation', async () => {
Expand Down Expand Up @@ -247,6 +251,7 @@ describe('the invitation API controller', () => {

describe('the generateInvitationLink method', () => {
it('should attempt to generate an invitation link', async () => {
dbMock.insert.mockResolvedValue({ id: 'test' })
const response = await supertest(app)
.post(`${PATH}/generate`)
.set('Authorization', 'Bearer test')
Expand All @@ -260,6 +265,8 @@ describe('the invitation API controller', () => {
})

it('should attempt to save the invitation in the db', async () => {
dbMock.insert.mockResolvedValue({ id: 'test' })

await supertest(app)
.post(`${PATH}/generate`)
.set('Authorization', 'Bearer test')
Expand Down
6 changes: 3 additions & 3 deletions packages/tom-server/src/invitation-api/tests/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const loggerMock = {
warn: jest.fn()
}

afterEach(() => {
jest.restoreAllMocks()
beforeEach(() => {
jest.resetAllMocks()
})

describe('the Invitation API service', () => {
Expand Down Expand Up @@ -53,7 +53,7 @@ describe('the Invitation API service', () => {
recepient: 'test',
medium: 'test',
expiration: 123456789,
accessed: true
accessed: false
}
])
})
Expand Down

0 comments on commit c9699b5

Please sign in to comment.