Skip to content

Commit

Permalink
Get transaction api for generator node test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Zikriya committed Jul 30, 2024
1 parent 3eba9b6 commit 3d8e91b
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/v1/nodInfra.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,51 @@ describe("API Endpoint Testing", () => {
expect(res.statusCode).toEqual(404);
});
});

describe("API Endpoint Testing", () => {
it("should return a list of swapPending transactions with status 200", async () => {
const res = await request(baseURL)
.get(
`${validTransactionListApiUrl}?status=swapPending&limit=20&nodeType=generator&address=${generatorNodePublicKey}`
)
.set(
"Authorization",
`Bearer ${await createAuthTokenForNodeInfra(generatorNodeApiKey)}`
);
expect(res.statusCode).toEqual(200);
expect(res.body.body).toHaveProperty("transactions");
});

it("should return an error with invalid token", async () => {
const res = await request(baseURL)
.get(
`${validTransactionListApiUrl}?status=swapPending&limit=20&nodeType=generator&address=${generatorNodePublicKey}`
)
.set("Authorization", "Bearer invalid_token");
expect(res.statusCode).toEqual(401);
});

it("should handle non-existent endpoint with status 404", async () => {
const res = await request(baseURL)
.get(
`${inValidTransactionListApiUrl}?status=swapPending&limit=20&nodeType=generator&address=${generatorNodePublicKey}`
)
.set(
"Authorization",
`Bearer ${await createAuthTokenForNodeInfra(generatorNodeApiKey)}`
);
expect(res.statusCode).toEqual(404);
});

it("should return 404 for invalid method (POST)", async () => {
const res = await request(baseURL)
.post(
`${validTransactionListApiUrl}?status=swapPending&limit=20&nodeType=generator&address=${generatorNodePublicKey}`
)
.set(
"Authorization",
`Bearer ${await createAuthTokenForNodeInfra(generatorNodeApiKey)}`
);
expect(res.statusCode).toEqual(404);
});
});

0 comments on commit 3d8e91b

Please sign in to comment.