forked from NuroDev/lemonsqueezy.ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
order.test.ts
38 lines (30 loc) · 976 Bytes
/
order.test.ts
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
import { describe, it, expect, beforeAll } from "vitest";
import { listAllOrders, retrieveOrder } from ".";
describe.concurrent("Order", () => {
const apiKey = process.env.LEMON_SQUEEZY_API_KEY as string;
beforeAll(() => {
if (!apiKey) throw "No LEMON_SQUEEZY_API_KEY environment variable found";
});
it("Retrieve order", async () => {
const orders = await listAllOrders({
apiKey,
});
if (!orders.data.length) throw new Error("No orders found");
const order = await retrieveOrder({
apiKey,
id: orders.data.at(0)!.id,
});
expect(order).toBeDefined();
expect(order.data).toBeDefined();
expect(order.data).not.toBeNull();
expect(order.errors).toBeUndefined();
});
it("List all orders", async () => {
const orders = await listAllOrders({
apiKey,
});
expect(orders).toBeDefined();
expect(Array.isArray(orders.data)).toBe(true);
expect(orders.errors).toBeUndefined();
});
});