File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 11import { vi } from "vitest" ;
22import { it } from "vitest" ;
33import { describe } from "vitest" ;
4- import { deleteSubdomain , getSubdomains } from "../src/commands/subdomains" ;
4+ import { createSubdomain , deleteSubdomain , getSubdomains } from "../src/commands/subdomains" ;
55import { expect } from "vitest" ;
66import { 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} )
You can’t perform that action at this time.
0 commit comments