Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
stbrody committed Jun 20, 2024
1 parent 2f08de6 commit b78f623
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/controllers/__tests__/request-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ describe('createRequest', () => {
expect(createdRequest.origin).toEqual(origin)
})

test('timestamp is empty', async () => {
test('timestamp is required', async () => {
const cid = randomCID()
const streamId = randomStreamID()
const now = new Date()
Expand All @@ -229,17 +229,7 @@ describe('createRequest', () => {
const requestRepository = container.resolve('requestRepository')
await expect(requestRepository.findByCid(cid)).resolves.toBeUndefined()
await controller.createRequest(req, res)
expect(res.status).toBeCalledWith(StatusCodes.CREATED)
const createdRequest = await requestRepository.findByCid(cid)
expectPresent(createdRequest)
expect(createdRequest.cid).toEqual(cid.toString())
expect(createdRequest.status).toEqual(RequestStatus.PENDING)
expect(createdRequest.streamId).toEqual(streamId.toString())
expect(createdRequest.message).toEqual('Request is pending.')
expect(isClose(createdRequest.timestamp.getTime(), now.getTime())).toBeTruthy()
expect(isClose(createdRequest.createdAt.getTime(), now.getTime())).toBeTruthy()
expect(isClose(createdRequest.updatedAt.getTime(), now.getTime())).toBeTruthy()
expect(createdRequest.origin).not.toBeNull()
expect(res.status).toBeCalledWith(StatusCodes.BAD_REQUEST)
})

test('mark previous submissions REPLACED', async () => {
Expand All @@ -249,6 +239,7 @@ describe('createRequest', () => {
body: {
cid: cid.toString(),
streamId: streamId.toString(),
timestamp: new Date().toISOString(),
},
})
const requestRepository = container.resolve('requestRepository')
Expand Down Expand Up @@ -332,6 +323,7 @@ describe('createRequest', () => {
body: {
cid: cid.toString(),
streamId: streamId.toString(),
timestamp: new Date().toISOString(),
},
})
const validationQueueService = container.resolve('validationQueueService')
Expand Down

0 comments on commit b78f623

Please sign in to comment.