Skip to content

Commit

Permalink
fix: Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmahidalgo committed Mar 7, 2022
1 parent 4994e57 commit 55ff34b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
5 changes: 5 additions & 0 deletions src/Collection/Collection.router.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,11 @@ describe('Collection router', () => {
created_at: item.created_at.toISOString(),
updated_at: item.updated_at.toISOString(),
})),
itemCurations: Array(3).fill({
...itemCurationMock,
created_at: itemCurationMock.created_at.toISOString(),
updated_at: itemCurationMock.updated_at.toISOString(),
}),
},
ok: true,
})
Expand Down
28 changes: 14 additions & 14 deletions src/Curation/Curation.router.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,12 @@ describe('when handling a request', () => {
.spyOn(service, 'getLatestById')
.mockResolvedValueOnce({ id: 'curationId' } as any)

jest
.spyOn(service, 'updateStatusAndReturnById')
.mockResolvedValueOnce(expectedCuration)

updateSpy = jest
.spyOn(CollectionCuration, 'update')
.spyOn(service, 'updateStatusAndReturnById')
.mockResolvedValueOnce(expectedCuration)
})

Expand All @@ -464,12 +468,8 @@ describe('when handling a request', () => {
await router.updateCollectionCuration(req)

expect(updateSpy).toHaveBeenCalledWith(
{
id: 'curationId',
status: CurationStatus.REJECTED,
updated_at: expect.any(String),
},
{ id: 'curationId' }
'curationId',
CurationStatus.REJECTED
)
})
})
Expand All @@ -485,6 +485,10 @@ describe('when handling a request', () => {
id: 'uuid-123123-123123',
} as ItemCurationAttributes

jest
.spyOn(service, 'updateStatusAndReturnById')
.mockResolvedValueOnce(expectedCuration)

jest
.spyOn(service, 'getLatestById')
.mockResolvedValueOnce({ id: 'curationId' } as any)
Expand All @@ -494,7 +498,7 @@ describe('when handling a request', () => {
.mockResolvedValueOnce({ rowCount: 1 })

itemUpdateSpy = jest
.spyOn(ItemCuration, 'update')
.spyOn(service, 'updateStatusAndReturnById')
.mockResolvedValueOnce(expectedCuration)
})

Expand All @@ -508,12 +512,8 @@ describe('when handling a request', () => {
await router.updateItemCuration(req)

expect(itemUpdateSpy).toHaveBeenCalledWith(
{
id: 'curationId',
status: CurationStatus.REJECTED,
updated_at: expect.any(String),
},
{ id: 'curationId' }
'curationId',
CurationStatus.REJECTED
)
})

Expand Down

0 comments on commit 55ff34b

Please sign in to comment.