diff --git a/tests/v1/nodInfra.test.ts b/tests/v1/nodInfra.test.ts index e0d15c6..2ec5e77 100644 --- a/tests/v1/nodInfra.test.ts +++ b/tests/v1/nodInfra.test.ts @@ -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); + }); +});