Skip to content

Commit

Permalink
add test for findThumbnail
Browse files Browse the repository at this point in the history
  • Loading branch information
fsimonjetz committed Mar 23, 2024
1 parent 12d2b19 commit 868e8eb
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/fragmentarium/infrastructure/ImageRepository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Promise from 'bluebird'
import ApiImageRepository from './ImageRepository'
import Folio from 'fragmentarium/domain/Folio'
import { folioFactory } from 'test-support/fragment-fixtures'
import { ThumbnailSize } from 'fragmentarium/application/FragmentService'

const image = new Blob([''], { type: 'image/jpeg' })

Expand Down Expand Up @@ -84,3 +85,26 @@ describe('findPhoto', () => {
await expect(promise).resolves.toEqual(image)
})
})

describe('findThumbnail', () => {
const number = 'ABC 123+456'
const size: ThumbnailSize = 'small'

beforeEach(async () => {
jest
.spyOn(apiClient, 'fetchBlob')
.mockReturnValueOnce(Promise.resolve(image))
promise = imageRepository.findThumbnail(number, size)
})

it('Queries the photo', () => {
expect(apiClient.fetchBlob).toBeCalledWith(
`/fragments/${encodeURIComponent(number)}/thumbnail/${size}`,
false
)
})

it('Resolves to blob', async () => {
await expect(promise).resolves.toEqual(image)
})
})

0 comments on commit 868e8eb

Please sign in to comment.