|
| 1 | +import { YepCodeApi } from "../../src/api/yepcodeApi"; |
| 2 | +import { ProcessesPaginatedResult } from "../../src/api/types"; |
| 3 | + |
| 4 | +const apiHost = process.env.YEPCODE_API_HOST; |
| 5 | +const apiToken = process.env.YEPCODE_API_TOKEN; |
| 6 | + |
| 7 | +let api: YepCodeApi; |
| 8 | + |
| 9 | +describe("YepCodeApi", () => { |
| 10 | + beforeAll(async () => { |
| 11 | + api = new YepCodeApi({ apiHost, apiToken }); |
| 12 | + }); |
| 13 | + |
| 14 | + describe("processes", () => { |
| 15 | + it("should return a paginated list of processes", async () => { |
| 16 | + const result: ProcessesPaginatedResult = await api.getProcesses(); |
| 17 | + |
| 18 | + expect(result).toHaveProperty("hasNextPage"); |
| 19 | + expect(result).toHaveProperty("page"); |
| 20 | + expect(result).toHaveProperty("limit"); |
| 21 | + expect(result).toHaveProperty("total"); |
| 22 | + expect(result).toHaveProperty("data"); |
| 23 | + expect(Array.isArray(result.data)).toBe(true); |
| 24 | + }); |
| 25 | + |
| 26 | + it("should return a paginated list of processes with a tag", async () => { |
| 27 | + const result: ProcessesPaginatedResult = await api.getProcesses({ |
| 28 | + tags: ["yc-run"], |
| 29 | + }); |
| 30 | + |
| 31 | + expect(result).toHaveProperty("hasNextPage"); |
| 32 | + expect(result).toHaveProperty("page"); |
| 33 | + expect(result).toHaveProperty("limit"); |
| 34 | + expect(result).toHaveProperty("total"); |
| 35 | + expect(result).toHaveProperty("data"); |
| 36 | + expect(Array.isArray(result.data)).toBe(true); |
| 37 | + }); |
| 38 | + }); |
| 39 | +}); |
0 commit comments