@@ -183,6 +183,11 @@ describe('AdminOrganizationsService', () => {
183183 const result = await service . getOrganization ( 'org_1' ) ;
184184 expect ( result . id ) . toBe ( 'org_1' ) ;
185185 expect ( result . members ) . toHaveLength ( 1 ) ;
186+ expect ( mockDb . organization . findUnique ) . toHaveBeenCalledWith (
187+ expect . objectContaining ( {
188+ select : expect . objectContaining ( { backgroundCheckStepEnabled : true } ) ,
189+ } ) ,
190+ ) ;
186191 } ) ;
187192
188193 it ( 'should throw NotFoundException for missing org' , async ( ) => {
@@ -194,8 +199,8 @@ describe('AdminOrganizationsService', () => {
194199 } ) ;
195200 } ) ;
196201
197- describe ( 'setAccess ' , ( ) => {
198- it ( 'should activate an organization ' , async ( ) => {
202+ describe ( 'updateOrganization ' , ( ) => {
203+ it ( 'single-field update (hasAccess) ' , async ( ) => {
199204 ( mockDb . organization . findUnique as jest . Mock ) . mockResolvedValue ( {
200205 id : 'org_1' ,
201206 } ) ;
@@ -204,7 +209,9 @@ describe('AdminOrganizationsService', () => {
204209 hasAccess : true ,
205210 } ) ;
206211
207- const result = await service . setAccess ( 'org_1' , true ) ;
212+ const result = await service . updateOrganization ( 'org_1' , {
213+ hasAccess : true ,
214+ } ) ;
208215
209216 expect ( result . success ) . toBe ( true ) ;
210217 expect ( mockDb . organization . update ) . toHaveBeenCalledWith ( {
@@ -213,30 +220,54 @@ describe('AdminOrganizationsService', () => {
213220 } ) ;
214221 } ) ;
215222
216- it ( 'should deactivate an organization ' , async ( ) => {
223+ it ( 'single-field update (backgroundCheckStepEnabled) ' , async ( ) => {
217224 ( mockDb . organization . findUnique as jest . Mock ) . mockResolvedValue ( {
218225 id : 'org_1' ,
219226 } ) ;
220227 ( mockDb . organization . update as jest . Mock ) . mockResolvedValue ( {
221228 id : 'org_1' ,
222- hasAccess : false ,
229+ backgroundCheckStepEnabled : false ,
223230 } ) ;
224231
225- const result = await service . setAccess ( 'org_1' , false ) ;
232+ const result = await service . updateOrganization ( 'org_1' , {
233+ backgroundCheckStepEnabled : false ,
234+ } ) ;
226235
227236 expect ( result . success ) . toBe ( true ) ;
228237 expect ( mockDb . organization . update ) . toHaveBeenCalledWith ( {
229238 where : { id : 'org_1' } ,
230- data : { hasAccess : false } ,
239+ data : { backgroundCheckStepEnabled : false } ,
231240 } ) ;
232241 } ) ;
233242
234- it ( 'should throw NotFoundException for missing org' , async ( ) => {
243+ it ( 'multi-field update' , async ( ) => {
244+ ( mockDb . organization . findUnique as jest . Mock ) . mockResolvedValue ( {
245+ id : 'org_1' ,
246+ } ) ;
247+ ( mockDb . organization . update as jest . Mock ) . mockResolvedValue ( {
248+ id : 'org_1' ,
249+ hasAccess : true ,
250+ backgroundCheckStepEnabled : false ,
251+ } ) ;
252+
253+ const result = await service . updateOrganization ( 'org_1' , {
254+ hasAccess : true ,
255+ backgroundCheckStepEnabled : false ,
256+ } ) ;
257+
258+ expect ( result . success ) . toBe ( true ) ;
259+ expect ( mockDb . organization . update ) . toHaveBeenCalledWith ( {
260+ where : { id : 'org_1' } ,
261+ data : { hasAccess : true , backgroundCheckStepEnabled : false } ,
262+ } ) ;
263+ } ) ;
264+
265+ it ( 'throws NotFoundException for missing org' , async ( ) => {
235266 ( mockDb . organization . findUnique as jest . Mock ) . mockResolvedValue ( null ) ;
236267
237- await expect ( service . setAccess ( 'org_missing' , true ) ) . rejects . toThrow (
238- NotFoundException ,
239- ) ;
268+ await expect (
269+ service . updateOrganization ( 'org_missing' , { hasAccess : true } ) ,
270+ ) . rejects . toThrow ( NotFoundException ) ;
240271 } ) ;
241272 } ) ;
242273
0 commit comments