Skip to content

Commit 636c6cc

Browse files
Add create subdomain test
1 parent bc4ea23 commit 636c6cc

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

tests/subdomains.test.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { vi } from "vitest";
22
import { it } from "vitest";
33
import { describe } from "vitest";
4-
import { deleteSubdomain, getSubdomains } from "../src/commands/subdomains";
4+
import { createSubdomain, deleteSubdomain, getSubdomains } from "../src/commands/subdomains";
55
import { expect } from "vitest";
66
import { getPuter } from "../src/modules/PuterModule";
77

@@ -47,4 +47,23 @@ describe("deleteSubdomain", () => {
4747
expect(result).toBe(true);
4848
expect(console.log).toHaveBeenCalledWith(expect.stringContaining("Subdomain deleted successfully"));
4949
})
50+
})
51+
52+
describe("createSubdomain", () => {
53+
it("should create subdomain successfully", async () => {
54+
const mockHostingCreate = vi.fn().mockResolvedValue({
55+
uid: "123",
56+
subdomain: "hehe.puter.site",
57+
root_dir: { path: "/some/path" },
58+
});
59+
vi.mocked(getPuter).mockReturnValue({
60+
hosting: {
61+
create: mockHostingCreate
62+
}
63+
})
64+
const result = await createSubdomain("hehe", "/mydir")
65+
expect(result).toMatchObject({
66+
subdomain: "hehe.puter.site"
67+
})
68+
})
5069
})

0 commit comments

Comments
 (0)