@@ -6,14 +6,20 @@ const EntityCoordinates = require('../../../../lib/entityCoordinates')
66const proxyquire = require ( 'proxyquire' )
77
88describe ( 'ListBasedFilterConfig' , ( ) => {
9- // Stub the logger used by the module to avoid initialization issues
10- const factory = proxyquire ( '../../../../providers/harvest/throttling/listBasedFilterConfig' , {
11- '../../logging/logger' : ( ) => ( {
12- debug : ( ) => { } ,
13- error : ( ) => { } ,
14- warn : ( ) => { }
9+ // Helper to create a factory with shared logger stub and optional overrides
10+ const makeFactory = overrides =>
11+ proxyquire ( '../../../../providers/harvest/throttling/listBasedFilterConfig' , {
12+ '../../logging/logger' : ( ) => ( {
13+ info : ( ) => { } ,
14+ debug : ( ) => { } ,
15+ error : ( ) => { } ,
16+ warn : ( ) => { }
17+ } ) ,
18+ ...( overrides || { } )
1519 } )
16- } )
20+
21+ // Stub the logger used by the module to avoid initialization issues
22+ const factory = makeFactory ( )
1723
1824 function createCoord ( coordString ) {
1925 return EntityCoordinates . fromString ( coordString )
@@ -85,14 +91,6 @@ describe('ListBasedFilterConfig', () => {
8591
8692 describe ( 'with mixed-type array' , ( ) => {
8793 it ( 'filters out non-string entries and blocks only string coordinates' , ( ) => {
88- const factory = proxyquire ( '../../../../providers/harvest/throttling/listBasedFilterConfig' , {
89- '../../logging/logger' : ( ) => ( {
90- debug : ( ) => { } ,
91- error : ( ) => { } ,
92- warn : ( ) => { }
93- } )
94- } )
95-
9694 const mixed = JSON . stringify ( [ 'npm/npmjs/-/left-pad' , 123 , null , { } , 'git/github/org/name' ] )
9795 const filter = factory ( mixed )
9896
@@ -104,15 +102,10 @@ describe('ListBasedFilterConfig', () => {
104102
105103 describe ( 'environment config' , ( ) => {
106104 it ( 'reads HARVEST_THROTTLER_BLACKLIST from config and blocks' , ( ) => {
107- const factoryFromEnv = proxyquire ( '../../../../providers/harvest/throttling/listBasedFilterConfig' , {
105+ const factoryFromEnv = makeFactory ( {
108106 'painless-config' : {
109107 get : key => ( key === 'HARVEST_THROTTLER_BLACKLIST' ? JSON . stringify ( [ 'git/github/org/name' ] ) : undefined )
110- } ,
111- '../../logging/logger' : ( ) => ( {
112- debug : ( ) => { } ,
113- error : ( ) => { } ,
114- warn : ( ) => { }
115- } )
108+ }
116109 } )
117110
118111 const filter = factoryFromEnv ( )
0 commit comments