-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost.test.js
More file actions
44 lines (37 loc) · 1.23 KB
/
post.test.js
File metadata and controls
44 lines (37 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import orchestrator from "tests/orchestrator.js";
beforeAll(async () => {
await orchestrator.waitForAllServices();
await orchestrator.clearDatabase();
});
describe("POST to api/v1/migrations", () => {
describe("Anonymous user", () => {
describe("Running pending migrations", () => {
test("For the first time", async () => {
// First run - should run migrations
const response = await fetch(
"http://localhost:3000/api/v1/migrations",
{
method: "POST",
},
);
const responseBody = await response.json();
expect(response.status).toBe(201);
expect(Array.isArray(responseBody)).toBe(true);
expect(responseBody.length).toBeGreaterThan(0);
});
test("For the second time", async () => {
// Second run - should not have migrations to run
const response1 = await fetch(
"http://localhost:3000/api/v1/migrations",
{
method: "POST",
},
);
const response1Body = await response1.json();
expect(response1.status).toBe(200);
expect(Array.isArray(response1Body)).toBe(true);
expect(response1Body.length).toBe(0);
});
});
});
});