feat: added logged in based testing by injecting jwt token logic

This commit is contained in:
Akhil Mohan
2024-01-27 12:38:23 +05:30
parent dd7c449483
commit 0506389ada
10 changed files with 125 additions and 28 deletions
+3 -3
View File
@@ -1,11 +1,11 @@
import { testUser } from "@app/db/seeds/1-user";
import { seedData1 } from "@app/db/seed-data";
import jsrp from "jsrp";
describe("Login V1 Router", async () => {
// eslint-disable-next-line
const client = new jsrp.client();
await new Promise((resolve) => {
client.init({ username: testUser.email, password: testUser.password }, () => resolve(null));
client.init({ username: seedData1.email, password: seedData1.password }, () => resolve(null));
});
let clientProof: string;
@@ -32,7 +32,7 @@ describe("Login V1 Router", async () => {
method: "POST",
url: "/api/v3/auth/login2",
body: {
email: testUser.email,
email: seedData1.email,
clientProof
}
});
+19
View File
@@ -0,0 +1,19 @@
import { seedData1 } from "@app/db/seed-data";
describe("Org V1 Router", async () => {
test("GET Org list", async () => {
const res = await testServer.inject({
method: "GET",
url: "/api/v1/organization",
headers: {
authorization: `Bearer ${jwtAuthToken}`
}
});
expect(res.statusCode).toBe(200);
const payload = JSON.parse(res.payload);
expect(payload).toHaveProperty("organizations");
expect(payload).toEqual({
organizations: [expect.objectContaining({ name: seedData1.organization.name })]
});
});
});
@@ -1,9 +0,0 @@
describe("Status V1 Router", async () => {
test("Simple check", async () => {
const res = await testServer.inject({
method: "GET",
url: "/api/status"
});
expect(res.statusCode).toBe(200);
});
});