@@ -35,6 +35,7 @@ import {
3535 TrustLevel ,
3636 isWorkspaceTrusted ,
3737} from './trustedFolders.js' ;
38+ import { Settings } from './settings.js' ;
3839
3940vi . mock ( 'fs' , async ( importOriginal ) => {
4041 const actualFs = await importOriginal < typeof fs > ( ) ;
@@ -130,6 +131,10 @@ describe('Trusted Folders Loading', () => {
130131describe ( 'isWorkspaceTrusted' , ( ) => {
131132 let mockCwd : string ;
132133 const mockRules : Record < string , TrustLevel > = { } ;
134+ const mockSettings : Settings = {
135+ folderTrustFeature : true ,
136+ folderTrust : true ,
137+ } ;
133138
134139 beforeEach ( ( ) => {
135140 vi . spyOn ( process , 'cwd' ) . mockImplementation ( ( ) => mockCwd ) ;
@@ -153,51 +158,51 @@ describe('isWorkspaceTrusted', () => {
153158 it ( 'should return true for a directly trusted folder' , ( ) => {
154159 mockCwd = '/home/user/projectA' ;
155160 mockRules [ '/home/user/projectA' ] = TrustLevel . TRUST_FOLDER ;
156- expect ( isWorkspaceTrusted ( ) ) . toBe ( true ) ;
161+ expect ( isWorkspaceTrusted ( mockSettings ) ) . toBe ( true ) ;
157162 } ) ;
158163
159164 it ( 'should return true for a child of a trusted folder' , ( ) => {
160165 mockCwd = '/home/user/projectA/src' ;
161166 mockRules [ '/home/user/projectA' ] = TrustLevel . TRUST_FOLDER ;
162- expect ( isWorkspaceTrusted ( ) ) . toBe ( true ) ;
167+ expect ( isWorkspaceTrusted ( mockSettings ) ) . toBe ( true ) ;
163168 } ) ;
164169
165170 it ( 'should return true for a child of a trusted parent folder' , ( ) => {
166171 mockCwd = '/home/user/projectB' ;
167172 mockRules [ '/home/user/projectB/somefile.txt' ] = TrustLevel . TRUST_PARENT ;
168- expect ( isWorkspaceTrusted ( ) ) . toBe ( true ) ;
173+ expect ( isWorkspaceTrusted ( mockSettings ) ) . toBe ( true ) ;
169174 } ) ;
170175
171176 it ( 'should return false for a directly untrusted folder' , ( ) => {
172177 mockCwd = '/home/user/untrusted' ;
173178 mockRules [ '/home/user/untrusted' ] = TrustLevel . DO_NOT_TRUST ;
174- expect ( isWorkspaceTrusted ( ) ) . toBe ( false ) ;
179+ expect ( isWorkspaceTrusted ( mockSettings ) ) . toBe ( false ) ;
175180 } ) ;
176181
177182 it ( 'should return undefined for a child of an untrusted folder' , ( ) => {
178183 mockCwd = '/home/user/untrusted/src' ;
179184 mockRules [ '/home/user/untrusted' ] = TrustLevel . DO_NOT_TRUST ;
180- expect ( isWorkspaceTrusted ( ) ) . toBeUndefined ( ) ;
185+ expect ( isWorkspaceTrusted ( mockSettings ) ) . toBeUndefined ( ) ;
181186 } ) ;
182187
183188 it ( 'should return undefined when no rules match' , ( ) => {
184189 mockCwd = '/home/user/other' ;
185190 mockRules [ '/home/user/projectA' ] = TrustLevel . TRUST_FOLDER ;
186191 mockRules [ '/home/user/untrusted' ] = TrustLevel . DO_NOT_TRUST ;
187- expect ( isWorkspaceTrusted ( ) ) . toBeUndefined ( ) ;
192+ expect ( isWorkspaceTrusted ( mockSettings ) ) . toBeUndefined ( ) ;
188193 } ) ;
189194
190195 it ( 'should prioritize trust over distrust' , ( ) => {
191196 mockCwd = '/home/user/projectA/untrusted' ;
192197 mockRules [ '/home/user/projectA' ] = TrustLevel . TRUST_FOLDER ;
193198 mockRules [ '/home/user/projectA/untrusted' ] = TrustLevel . DO_NOT_TRUST ;
194- expect ( isWorkspaceTrusted ( ) ) . toBe ( true ) ;
199+ expect ( isWorkspaceTrusted ( mockSettings ) ) . toBe ( true ) ;
195200 } ) ;
196201
197202 it ( 'should handle path normalization' , ( ) => {
198203 mockCwd = '/home/user/projectA' ;
199204 mockRules [ `/home/user/../user/${ path . basename ( '/home/user/projectA' ) } ` ] =
200205 TrustLevel . TRUST_FOLDER ;
201- expect ( isWorkspaceTrusted ( ) ) . toBe ( true ) ;
206+ expect ( isWorkspaceTrusted ( mockSettings ) ) . toBe ( true ) ;
202207 } ) ;
203208} ) ;
0 commit comments