@@ -108,6 +108,12 @@ describe('image-checker', () => {
108108 expect ( result ) . toEqual ( { success : true , skipped : true } )
109109 } )
110110
111+ it ( 'returns skipped result when thumbnails argument is omitted' , async ( ) => {
112+ const result = await imageChecker . validate ( )
113+
114+ expect ( result ) . toEqual ( { success : true , skipped : true } )
115+ } )
116+
111117 it ( 'does not call post when no thumbnails are supplied' , async ( ) => {
112118 await imageChecker . validate ( [ ] )
113119
@@ -122,6 +128,66 @@ describe('image-checker', () => {
122128 expect ( result ) . toEqual ( { success : true , skipped : true } )
123129 } )
124130
131+ it . each ( [
132+ {
133+ label : 'endpoint is missing' ,
134+ endpoint : '' ,
135+ key : 'test-content-safety-key'
136+ } ,
137+ {
138+ label : 'key is missing' ,
139+ endpoint : 'https://example.cognitiveservices.azure.com/' ,
140+ key : ''
141+ }
142+ ] ) ( 'returns skipped result when content safety config is incomplete: $label' , async ( { endpoint, key } ) => {
143+ process . env . CONTENT_SAFETY_ENDPOINT = endpoint
144+ process . env . CONTENT_SAFETY_KEY = key
145+
146+ const result = await imageChecker . validate ( [ { finalFilename : 'upload-id/photo1.jpg' } ] )
147+
148+ expect ( result ) . toEqual ( { success : true , skipped : true } )
149+ } )
150+
151+ it . each ( [
152+ {
153+ label : 'endpoint is missing' ,
154+ endpoint : '' ,
155+ key : 'test-content-safety-key'
156+ } ,
157+ {
158+ label : 'key is missing' ,
159+ endpoint : 'https://example.cognitiveservices.azure.com/' ,
160+ key : ''
161+ }
162+ ] ) ( 'does not create content safety client when config is incomplete: $label' , async ( { endpoint, key } ) => {
163+ process . env . CONTENT_SAFETY_ENDPOINT = endpoint
164+ process . env . CONTENT_SAFETY_KEY = key
165+
166+ await imageChecker . validate ( [ { finalFilename : 'upload-id/photo1.jpg' } ] )
167+
168+ expect ( ContentSafetyClient ) . not . toHaveBeenCalled ( )
169+ } )
170+
171+ it . each ( [
172+ {
173+ label : 'endpoint is missing' ,
174+ endpoint : '' ,
175+ key : 'test-content-safety-key'
176+ } ,
177+ {
178+ label : 'key is missing' ,
179+ endpoint : 'https://example.cognitiveservices.azure.com/' ,
180+ key : ''
181+ }
182+ ] ) ( 'does not fetch blob container when config is incomplete: $label' , async ( { endpoint, key } ) => {
183+ process . env . CONTENT_SAFETY_ENDPOINT = endpoint
184+ process . env . CONTENT_SAFETY_KEY = key
185+
186+ await imageChecker . validate ( [ { finalFilename : 'upload-id/photo1.jpg' } ] )
187+
188+ expect ( blobStorage . getUploadContainerClient ) . not . toHaveBeenCalled ( )
189+ } )
190+
125191 it ( 'does not call post when blob container client is unavailable' , async ( ) => {
126192 blobStorage . getUploadContainerClient . mockResolvedValue ( null )
127193 isUnexpected . mockReturnValue ( false )
0 commit comments