Skip to content

Commit

Permalink
tests(integration): fixing check for UUIDv4 format and check on error…
Browse files Browse the repository at this point in the history
… response (#397)
  • Loading branch information
geekbrother authored Nov 27, 2023
1 parent 540cbc1 commit 80228a5
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions integration/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,26 @@ describe('blockchain api', () => {
})
})
describe('Middlewares', () => {
it('headers should contain x-request-id', async () => {
it('OK response should contain x-request-id header', async () => {
let resp: any = await http.get(
`${baseUrl}/v1/account/0xf3ea39310011333095CFCcCc7c4Ad74034CABA63/history?projectId=${projectId}`,
)
expect(resp.status).toBe(200)
expect(resp.header['x-request-id']).toBe('string');
expect(resp.header['x-request-id']).toHaveLength(36); // UUIDv4
expect(resp.headers).toBeDefined();
expect(resp.status).toBe(200);
// Check if the header value is a valid UUIDv4
const uuidv4Pattern = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
expect(resp.headers['x-request-id']).toMatch(uuidv4Pattern);
})
it('Error response should contain x-request-id header', async () => {
// Wrong address request
let resp: any = await http.get(
`${baseUrl}/v1/account/0Ff3ea39310011333095CFCcCc7c4Ad74034CABA63/history?projectId=${projectId}`,
)
expect(resp.headers).toBeDefined();
expect(resp.status).toBe(400);
// Check if the header value is a valid UUIDv4
const uuidv4Pattern = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
expect(resp.headers['x-request-id']).toMatch(uuidv4Pattern);
})
})
describe('Identity', () => {
Expand Down

0 comments on commit 80228a5

Please sign in to comment.