@@ -28,4 +28,86 @@ describe("MyBusinessUnit", () => {
2828 expect ( response . body . count ) . toBeGreaterThanOrEqual ( 0 ) ;
2929 expect ( response . body . results ) . toBeDefined ( ) ;
3030 } ) ;
31+
32+ test ( "Get my business unit by ID" , async ( ) => {
33+ // First create a business unit
34+ const draft : BusinessUnitDraft = {
35+ key : "my-business-unit" ,
36+ unitType : "Company" ,
37+ name : "My Business Unit" ,
38+ contactEmail : "contact@example.com" ,
39+ } ;
40+ const createResponse = await supertest ( ctMock . app )
41+ . post ( "/dummy/business-units" )
42+ . send ( draft ) ;
43+
44+ expect ( createResponse . status ) . toBe ( 201 ) ;
45+
46+ const response = await supertest ( ctMock . app ) . get (
47+ `/dummy/me/business-units/${ createResponse . body . id } ` ,
48+ ) ;
49+
50+ expect ( response . status ) . toBe ( 200 ) ;
51+ expect ( response . body ) . toEqual ( createResponse . body ) ;
52+ } ) ;
53+
54+ test ( "Delete my business unit" , async ( ) => {
55+ // First create a business unit
56+ const draft : BusinessUnitDraft = {
57+ key : "my-business-unit" ,
58+ unitType : "Company" ,
59+ name : "My Business Unit" ,
60+ contactEmail : "contact@example.com" ,
61+ } ;
62+ const createResponse = await supertest ( ctMock . app )
63+ . post ( "/dummy/business-units" )
64+ . send ( draft ) ;
65+
66+ expect ( createResponse . status ) . toBe ( 201 ) ;
67+
68+ // Now delete the business unit
69+ const deleteResponse = await supertest ( ctMock . app ) . delete (
70+ `/dummy/me/business-units/${ createResponse . body . id } ` ,
71+ ) ;
72+
73+ expect ( deleteResponse . status ) . toBe ( 200 ) ;
74+ expect ( deleteResponse . body ) . toEqual ( createResponse . body ) ;
75+
76+ // Verify that the business unit is deleted
77+ const newResponse = await supertest ( ctMock . app ) . get (
78+ `/dummy/me/business-units/${ createResponse . body . id } ` ,
79+ ) ;
80+ expect ( newResponse . status ) . toBe ( 404 ) ;
81+ } ) ;
82+
83+ test ( "Update my business unit" , async ( ) => {
84+ // First create a business unit
85+ const draft : BusinessUnitDraft = {
86+ key : "my-business-unit" ,
87+ unitType : "Company" ,
88+ name : "My Business Unit" ,
89+ contactEmail : "contact@example.com" ,
90+ } ;
91+ const createResponse = await supertest ( ctMock . app )
92+ . post ( "/dummy/business-units" )
93+ . send ( draft ) ;
94+
95+ expect ( createResponse . status ) . toBe ( 201 ) ;
96+
97+ const updateResponse = await supertest ( ctMock . app )
98+ . post ( `/dummy/me/business-units/${ createResponse . body . id } ` )
99+ . send ( {
100+ id : createResponse . body . id ,
101+ version : createResponse . body . version ,
102+ actions : [
103+ {
104+ action : "changeName" ,
105+ name : "Updated Business Unit Name" ,
106+ } ,
107+ ] ,
108+ } ) ;
109+
110+ expect ( updateResponse . status ) . toBe ( 200 ) ;
111+ expect ( updateResponse . body . name ) . toBe ( "Updated Business Unit Name" ) ;
112+ } ) ;
31113} ) ;
0 commit comments