Skip to content

Commit

Permalink
test: rename all descriptions to use new pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
AlAnNuB authored Sep 11, 2024
1 parent ee34dd8 commit 10d8cdb
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 31 deletions.
16 changes: 10 additions & 6 deletions tests/integration/api/v1/migrations/get.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ beforeAll(async () => {
await database.query("DROP SCHEMA public CASCADE; CREATE SCHEMA public;");
});

test("GET to /api/v1/status 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("Running pending migrations", async () => {
const response = await fetch("http://localhost:3000/api/v1/migrations");
expect(response.status).toBe(200);

const responseBody = await response.json();
const responseBody = await response.json();

expect(Array.isArray(responseBody)).toBe(true);
expect(responseBody.length).toBeGreaterThan(0);
expect(Array.isArray(responseBody)).toBe(true);
expect(responseBody.length).toBeGreaterThan(0);
});
});
});
40 changes: 24 additions & 16 deletions tests/integration/api/v1/migrations/post.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,32 @@ beforeAll(async () => {
await database.query("DROP SCHEMA public CASCADE; CREATE SCHEMA public;");
});

test("POST to /api/v1/status should return 200", async () => {
const response1 = await fetch("http://localhost:3000/api/v1/migrations", {
method: "POST",
});
expect(response1.status).toBe(201);

const response1Body = await response1.json();
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);

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();
const response2Body = await response2.json();

expect(Array.isArray(response2Body)).toBe(true);
expect(response2Body.length).toBe(0);
expect(Array.isArray(response2Body)).toBe(true);
expect(response2Body.length).toBe(0);
});
});
});
});

22 changes: 13 additions & 9 deletions tests/integration/api/v1/status/get.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ 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();
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 10d8cdb

Please sign in to comment.