|
1 | 1 | import assert from "node:assert/strict"; |
2 | | -import test from "node:test"; |
3 | | -import { setTimeout } from "node:timers/promises"; |
| 2 | +import { describe, it } from "node:test"; |
4 | 3 | import path from "path"; |
5 | 4 | import { fileURLToPath } from "url"; |
6 | 5 | import { readFile } from "fs/promises"; |
7 | 6 | import { SquareCloudAPI } from "../lib/index.js"; |
8 | 7 |
|
9 | 8 | const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
10 | 9 |
|
11 | | -test("ApplicationsModule", async (t) => { |
| 10 | +describe("ApplicationsModule", async () => { |
12 | 11 | const client = new SquareCloudAPI(process.env.SQUARE_API_KEY); |
13 | 12 |
|
14 | | - await t.test("should list all applications", async () => { |
| 13 | + await it("should list all applications", async () => { |
15 | 14 | const applications = await client.applications.get(); |
16 | 15 | assert.ok(applications); |
17 | 16 | assert.ok(applications.size >= 0); |
18 | 17 | }); |
19 | 18 |
|
20 | | - await t.test("should handle application lifecycle", async (t) => { |
| 19 | + await describe("Lifecycle", async (t) => { |
21 | 20 | const testAppPath = path.join(__dirname, "fixtures/test-app.zip"); |
22 | 21 | const fileContent = await readFile(testAppPath); |
23 | 22 |
|
24 | 23 | const createdApp = await client.applications.create(fileContent); |
25 | 24 |
|
26 | | - await t.test("should create application", async () => { |
| 25 | + await it("should create application", async () => { |
27 | 26 | assert.ok(createdApp); |
28 | 27 | assert.ok(createdApp.id); |
29 | 28 | }); |
30 | 29 |
|
31 | 30 | const app = await client.applications.fetch(createdApp.id); |
32 | 31 |
|
33 | | - await t.test("should fetch application", async () => { |
| 32 | + await it("should fetch application", async () => { |
34 | 33 | assert.strictEqual(app.id, createdApp.id); |
35 | 34 | }); |
36 | 35 |
|
37 | | - await t.test("should get status", async () => { |
| 36 | + await it("should get status", async () => { |
38 | 37 | const status = await app.getStatus(); |
39 | 38 | assert.strictEqual(status.applicationId, createdApp.id); |
40 | 39 | }); |
41 | 40 |
|
42 | | - await t.test("should get application logs", async () => { |
| 41 | + await it("should get application logs", async () => { |
43 | 42 | const logs = await app.getLogs(); |
44 | 43 | assert.ok(typeof logs === "string"); |
45 | 44 | }); |
46 | 45 |
|
47 | 46 | const testFilePath = path.join(__dirname, "fixtures/test-file.txt"); |
48 | 47 |
|
49 | | - await t.test("should commit files as buffer to application", async () => { |
50 | | - const fileContent = await readFile(testFilePath); |
51 | | - |
52 | | - const bufferResult = await app.commit(fileContent, "test-file.txt"); |
53 | | - assert.strictEqual(bufferResult, true); |
54 | | - }); |
55 | | - |
56 | | - await setTimeout(10000); |
57 | | - |
58 | | - await t.test("should commit files as path to application", async () => { |
59 | | - const pathResult = await app.commit(testFilePath, "test-file2.txt"); |
| 48 | + await it("should commit file to application", async () => { |
| 49 | + const pathResult = await app.commit(testFilePath, "test-file.txt"); |
60 | 50 | assert.strictEqual(pathResult, true); |
61 | 51 | }); |
62 | 52 |
|
63 | | - await t.test("should start application", async () => { |
64 | | - const result = await app.start(); |
| 53 | + await it("should stop application", async () => { |
| 54 | + const result = await app.stop(); |
65 | 55 | assert.strictEqual(result, true); |
66 | 56 | }); |
67 | 57 |
|
68 | | - await t.test("should restart application", async () => { |
69 | | - const result = await app.restart(); |
| 58 | + await it("should start application", async () => { |
| 59 | + const result = await app.start(); |
70 | 60 | assert.strictEqual(result, true); |
71 | 61 | }); |
72 | 62 |
|
73 | | - await t.test("should stop application", async () => { |
74 | | - const result = await app.stop(); |
| 63 | + await it("should restart application", async () => { |
| 64 | + const result = await app.restart(); |
75 | 65 | assert.strictEqual(result, true); |
76 | 66 | }); |
77 | 67 |
|
78 | | - await t.test("should delete application", async () => { |
| 68 | + await it("should delete application", async () => { |
79 | 69 | const deleteResult = await app.delete(); |
80 | 70 | assert.strictEqual(deleteResult, true); |
81 | 71 | }); |
82 | 72 | }); |
83 | 73 |
|
84 | | - await t.test("should get status for all applications", async () => { |
| 74 | + await it("should get status for all applications", async () => { |
85 | 75 | const statuses = await client.applications.statusAll(); |
86 | 76 | assert.ok(Array.isArray(statuses)); |
87 | 77 | }); |
|
0 commit comments