Skip to content

Commit

Permalink
test: rename all descriptions for all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemaion authored Oct 23, 2024
1 parent de839b8 commit b45a3f5
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 34 deletions.
19 changes: 12 additions & 7 deletions tests/integration/api/v1/migrations/get.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ beforeAll(async () => {
await database.query("drop schema public cascade; create schema public;");
});

test("GET to /api/v1/migrations should return 200", async () => {
const response = await fetch("http://localhost:3000/api/v1/migrations");
expect(response.status).toBe(200);
describe("GET /api/v1/migrations", () => {
describe("Anonymous user", () => {
test("Retrieving pending migrations", async () => {
const response = await fetch("http://localhost:3000/api/v1/migrations");
expect(response.status).toBe(200);

const responseBody = await response.json();
expect(Array.isArray(responseBody)).toBe(true);
expect(responseBody.length).toBeGreaterThan(0);
});
const responseBody = await response.json();

expect(Array.isArray(responseBody)).toBe(true);
expect(responseBody.length).toBeGreaterThan(0);
});
});
});
47 changes: 31 additions & 16 deletions tests/integration/api/v1/migrations/post.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,37 @@ beforeAll(async () => {
await database.query("drop schema public cascade; create schema public;");
});

test("POST to /api/v1/migrations should return 200", async () => {
const response1 = await fetch("http://localhost:3000/api/v1/migrations", {
method: "POST",
});
expect(response1.status).toBe(201);
describe("POST /api/v1/migrations", () => {
describe("Anonymous user", () => {
describe("Running pending migrations", () => {
test("For the first time", async () => {
const response1 = await fetch(
"http://localhost:3000/api/v1/migrations",
{
method: "POST",
},
);
expect(response1.status).toBe(201);

const response1Body = await response1.json();
expect(Array.isArray(response1Body)).toBe(true);
expect(response1Body.length).toBeGreaterThan(0);
const response1Body = await response1.json();

const response2 = await fetch("http://localhost:3000/api/v1/migrations", {
method: "POST",
});
expect(response2.status).toBe(200);
expect(Array.isArray(response1Body)).toBe(true);
expect(response1Body.length).toBeGreaterThan(0);
});
test("For the second time", async () => {
const response2 = await fetch(
"http://localhost:3000/api/v1/migrations",
{
method: "POST",
},
);
expect(response2.status).toBe(200);

const response2Body = await response2.json();
expect(Array.isArray(response2Body)).toBe(true);
expect(response2Body.length).toBe(0);
});
const response2Body = await response2.json();

expect(Array.isArray(response2Body)).toBe(true);
expect(response2Body.length).toBe(0);
});
});
});
});
25 changes: 14 additions & 11 deletions tests/integration/api/v1/status/get.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ import orchestrator from "tests/orchestrator.js";
beforeAll(async () => {
await orchestrator.waitForAllServices();
});
test("GET to /api/v1/status should return 200", async () => {
const response = await fetch("http://localhost:3000/api/v1/status");
expect(response.status).toBe(200);
describe("GET /api/v1/status", () => {
describe("Anonymous user", () => {
test("Retrieving current system status", async () => {
const response = await fetch("http://localhost:3000/api/v1/status");
expect(response.status).toBe(200);

const responseBody = await response.json();
expect(responseBody.updated_at).toBeDefined();
const responseBody = await response.json();

const parsedUpdatedAt = new Date(responseBody.updated_at).toISOString();
expect(responseBody.updated_at).toEqual(parsedUpdatedAt);
const parsedUpdatedAt = new Date(responseBody.updated_at).toISOString();
expect(responseBody.updated_at).toEqual(parsedUpdatedAt);

expect(responseBody.dependencies.database.version).toEqual("16.0");
expect(responseBody.dependencies.database.max_connections).toEqual(100);
expect(responseBody.dependencies.database.opened_connections).toEqual(1);
});
expect(responseBody.dependencies.database.version).toEqual("16.0");
expect(responseBody.dependencies.database.max_connections).toEqual(100);
expect(responseBody.dependencies.database.opened_connections).toEqual(1);
});
});
});

0 comments on commit b45a3f5

Please sign in to comment.