Skip to content

Commit

Permalink
Merge pull request #422 from zikriya/develop
Browse files Browse the repository at this point in the history
Get transaction api for generator node test cases
  • Loading branch information
zikriya authored Jul 30, 2024
2 parents 64c75d0 + 3d8e91b commit edacc9c
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 edacc9c

Please sign in to comment.