File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,38 @@ describe('ConfigLoader', () => {
118
118
expect ( spy . firstCall . args [ 0 ] ) . to . deep . include ( newConfig ) ;
119
119
} ) ;
120
120
121
+ it ( 'should emit a single event when config changes' , async ( ) => {
122
+ const initialConfig = {
123
+ configurationSources : {
124
+ enabled : true ,
125
+ sources : [
126
+ {
127
+ type : 'file' ,
128
+ enabled : true ,
129
+ path : tempConfigFile ,
130
+ } ,
131
+ ] ,
132
+ reloadIntervalSeconds : 0 ,
133
+ } ,
134
+ } ;
135
+
136
+ const newConfig = {
137
+ proxyUrl : 'https://new-test.com' ,
138
+ } ;
139
+
140
+ fs . writeFileSync ( tempConfigFile , JSON . stringify ( newConfig ) ) ;
141
+
142
+ configLoader = new ConfigLoader ( initialConfig ) ;
143
+ const spy = sinon . spy ( ) ;
144
+ configLoader . on ( 'configurationChanged' , spy ) ;
145
+
146
+ await configLoader . reloadConfiguration ( ) ;
147
+ await configLoader . reloadConfiguration ( ) ;
148
+
149
+ expect ( spy . calledOnce ) . to . be . true ;
150
+ expect ( spy . firstCall . args [ 0 ] ) . to . deep . include ( newConfig ) ;
151
+ } ) ;
152
+
121
153
it ( 'should not emit event if config has not changed' , async ( ) => {
122
154
const testConfig = {
123
155
proxyUrl : 'https://test.com' ,
You can’t perform that action at this time.
0 commit comments