Skip to content

Commit

Permalink
rename items field for tx history endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
0xChqrles committed Jun 20, 2024
1 parent 74c976e commit 2728db3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion backend/src/routes/getTransactionHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function getTransactionHistory(fastify: FastifyInstance) {

const hasNext = txs.length > first

return reply.status(200).send({ transactions: txs.slice(0, first), endCursor, hasNext })
return reply.status(200).send({ items: txs.slice(0, first), endCursor, hasNext })
} catch (error) {
console.error(error)
return reply.status(500).send({ error: 'Internal server error' })
Expand Down
16 changes: 8 additions & 8 deletions backend/test/getTransactionHistory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ describe('GET /transaction history route', () => {
expect(response.statusCode).toBe(200)

const mockResponseObj = generateMockData(testAddress, first, startValue, true, test_user)
expect(response.json().transactions).toMatchObject(mockResponseObj)
expect(response.json().transactions).toHaveLength(first)
expect(response.json().items).toMatchObject(mockResponseObj)
expect(response.json().items).toHaveLength(first)
})

test('should return the first 9 entries', async () => {
Expand All @@ -137,8 +137,8 @@ describe('GET /transaction history route', () => {
expect(response.statusCode).toBe(200)

const mockResponseObj = generateMockData(testAddress, first, startValue, true, test_user)
expect(response.json().transactions).toMatchObject(mockResponseObj)
expect(response.json().transactions).toHaveLength(first)
expect(response.json().items).toMatchObject(mockResponseObj)
expect(response.json().items).toHaveLength(first)
})
test('should return all the txs', async () => {
const txsNb = 10
Expand All @@ -152,8 +152,8 @@ describe('GET /transaction history route', () => {
expect(response.statusCode).toBe(200)

const mockResponseObj = generateMockData(testAddress, txsNb, 0, true, test_user)
expect(response.json().transactions).toMatchObject(mockResponseObj)
expect(response.json().transactions).toHaveLength(txsNb)
expect(response.json().items).toMatchObject(mockResponseObj)
expect(response.json().items).toHaveLength(txsNb)
})

test('should return empty list unknown address', async () => {
Expand All @@ -166,8 +166,8 @@ describe('GET /transaction history route', () => {

expect(response.statusCode).toBe(200)

expect(response.json().transactions).toMatchObject([])
expect(response.json().transactions).toHaveLength(0)
expect(response.json().items).toMatchObject([])
expect(response.json().items).toHaveLength(0)
})

test('should return an error wrong address format', async () => {
Expand Down

0 comments on commit 2728db3

Please sign in to comment.