@@ -293,6 +293,14 @@ describe("Unit tests for getSaltValue", () => {
293293 } )
294294} )
295295describe ( "Unit tests for checkSiteOrSystemIsNotifyEnabled" , ( ) => {
296+ let logger : Logger
297+ let infoSpy : SpiedFunction < ( input : LogItemMessage , ...extraInput : LogItemExtraInput ) => void >
298+ beforeEach ( ( ) => {
299+ // Fresh logger and spies
300+ logger = new Logger ( { serviceName : "test-service" } )
301+ infoSpy = jest . spyOn ( logger , "info" )
302+ } )
303+
296304 it ( "includes an item with an enabled ODS code" , async ( ) => {
297305 const previous = createMockDataItem ( {
298306 PharmacyODSCode : "FA565" ,
@@ -303,8 +311,9 @@ describe("Unit tests for checkSiteOrSystemIsNotifyEnabled", () => {
303311 PharmacyODSCode : "FA565" ,
304312 ApplicationName : "not a real test supplier"
305313 } )
306- const result = await checkSiteOrSystemIsNotifyEnabled ( [ { previous, current} ] )
314+ const result = await checkSiteOrSystemIsNotifyEnabled ( [ { previous, current} ] , logger )
307315 expect ( result ) . toStrictEqual ( [ { previous, current} ] )
316+ expectLogReceivedAndAllowed ( infoSpy , 1 , 1 )
308317 } )
309318
310319 it ( "includes an item with an enabled ApplicationName" , async ( ) => {
@@ -317,8 +326,9 @@ describe("Unit tests for checkSiteOrSystemIsNotifyEnabled", () => {
317326 PharmacyODSCode : "ZZZ999" ,
318327 ApplicationName : "Internal Test System"
319328 } )
320- const result = await checkSiteOrSystemIsNotifyEnabled ( [ { previous, current} ] )
329+ const result = await checkSiteOrSystemIsNotifyEnabled ( [ { previous, current} ] , logger )
321330 expect ( result ) . toEqual ( [ { previous, current} ] )
331+ expectLogReceivedAndAllowed ( infoSpy , 1 , 1 )
322332 } )
323333
324334 it ( "is case insensitive for both ODS code and ApplicationName" , async ( ) => {
@@ -339,7 +349,7 @@ describe("Unit tests for checkSiteOrSystemIsNotifyEnabled", () => {
339349 previous : item2 ,
340350 current : item2
341351 }
342- ] )
352+ ] , logger )
343353 expect ( result ) . toEqual ( [
344354 {
345355 previous : item1 ,
@@ -362,8 +372,9 @@ describe("Unit tests for checkSiteOrSystemIsNotifyEnabled", () => {
362372 PharmacyODSCode : "b3j1z" ,
363373 ApplicationName : "Internal Test System"
364374 } )
365- const result = await checkSiteOrSystemIsNotifyEnabled ( [ { previous, current} ] )
375+ const result = await checkSiteOrSystemIsNotifyEnabled ( [ { previous, current} ] , logger )
366376 expect ( result ) . toEqual ( [ ] )
377+ expectLogReceivedAndAllowed ( infoSpy , 1 , 0 )
367378 } )
368379
369380 it ( "excludes items that are neither enabled nor blocked" , async ( ) => {
@@ -376,8 +387,18 @@ describe("Unit tests for checkSiteOrSystemIsNotifyEnabled", () => {
376387 PharmacyODSCode : "NOTINLIST" ,
377388 ApplicationName : "Some Other System"
378389 } )
379- const result = await checkSiteOrSystemIsNotifyEnabled ( [ { previous, current} ] )
390+ const result = await checkSiteOrSystemIsNotifyEnabled ( [ { previous, current} ] , logger )
380391 expect ( result ) . toEqual ( [ ] )
392+ expectLogReceivedAndAllowed ( infoSpy , 1 , 0 )
381393 } )
382394
383395} )
396+ function expectLogReceivedAndAllowed (
397+ infoSpy : SpiedFunction < ( input : LogItemMessage , ...extraInput : LogItemExtraInput ) => void > ,
398+ numItemsReceived : number ,
399+ numItemsAllowed : number ) {
400+ expect ( infoSpy ) . toHaveBeenCalledWith (
401+ expect . stringContaining ( "Filtered out sites and suppliers that are not enabled, or are explicitly disabled" ) ,
402+ expect . objectContaining ( { numItemsReceived, numItemsAllowed} )
403+ )
404+ }
0 commit comments