-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathgetCourse.test.ts
More file actions
36 lines (34 loc) · 1.06 KB
/
getCourse.test.ts
File metadata and controls
36 lines (34 loc) · 1.06 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
process.env.NEXT_PUBLIC_SOROBAN_RPC_URL = "http://mock-rpc-url";
process.env.NEXT_PUBLIC_COURSE_REGISTRY_CONTRACT_ID = "mock-contract-id";
import { getCourse } from "./src/contract_connections/CourseRegistry/getCourse";
// Mock SorobanClient.Server and its getContractValue method
jest.mock("@stellar/stellar-sdk", () => ({
Server: jest.fn().mockImplementation(() => ({
getContractValue: jest.fn().mockResolvedValue({
title: "Mock Course",
description: "Mock Description",
creator: "Mock Creator",
price: "100",
category: "Mock Category",
language: "en",
published: true,
thumbnail_url: "",
}),
})),
}));
describe("getCourse", () => {
it("returns mocked course data", async () => {
const course = await getCourse("mock-id");
expect(course).toEqual({
id: "mock-id",
title: "Mock Course",
description: "Mock Description",
creator: "Mock Creator",
price: "100",
category: "Mock Category",
language: "en",
published: true,
thumbnail_url: "",
});
});
});