Skip to content

Commit

Permalink
test: change assert
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmahidalgo committed Apr 6, 2022
1 parent 83bfc50 commit b800d2e
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/Curation/Curation.router.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
dbCollectionMock,
dbTPCollectionMock,
} from '../../spec/mocks/collections'
import { itemCurationMock } from '../../spec/mocks/itemCuration'
import { dbItemMock, thirdPartyItemFragmentMock } from '../../spec/mocks/items'
import { thirdPartyAPI } from '../ethereum/api/thirdParty'
import { collectionAPI } from '../ethereum/api/collection'
Expand Down Expand Up @@ -260,29 +261,23 @@ describe('when handling a request', () => {

describe('when itemIds param is provided', () => {
let itemIds: string[]
let itemCuration: ItemCurationAttributes
beforeEach(() => {
itemIds = ['1', '2', '3']
;(ItemCuration.findByCollectionId as jest.Mock).mockResolvedValueOnce(
[]
itemCuration = { ...itemCurationMock }
;(ItemCuration.findByCollectionAndItemIds as jest.Mock).mockResolvedValueOnce(
[itemCuration]
)
})

it('should resolve with the collections provided by ItemCuration.findByCollectionAndItemIds', async () => {
const findByCollectionAndItemIdsSpy = jest
.spyOn(ItemCuration, 'findByCollectionAndItemIds')
.mockResolvedValueOnce([])

const req = {
params: { id: 'collectionId', itemIds },
auth: { ethAddress: 'ethAddress' },
} as any

await router.getCollectionItemCurations(req)

expect(findByCollectionAndItemIdsSpy).toHaveBeenCalledWith(
'collectionId',
itemIds
)
const itemCurations = await router.getCollectionItemCurations(req)
expect(itemCurations).toStrictEqual([itemCuration])
})
})
})
Expand Down

0 comments on commit b800d2e

Please sign in to comment.