File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -117,5 +117,24 @@ describe('debug', () => {
117
117
assert . deepStrictEqual ( oldNames . map ( String ) , debug . names . map ( String ) ) ;
118
118
assert . deepStrictEqual ( oldSkips . map ( String ) , debug . skips . map ( String ) ) ;
119
119
} ) ;
120
+
121
+ it ( 'handles re-enabling existing instances' , ( ) => {
122
+ debug . disable ( '*' ) ;
123
+ const inst = debug ( 'foo' ) ;
124
+ const messages = [ ] ;
125
+ inst . log = msg => messages . push ( msg . replace ( / ^ [ ^ @ ] * @ ( [ ^ @ ] + ) @ .* $ / , '$1' ) ) ;
126
+
127
+ inst ( '@test@' ) ;
128
+ assert . deepStrictEqual ( messages , [ ] ) ;
129
+ debug . enable ( 'foo' ) ;
130
+ assert . deepStrictEqual ( messages , [ ] ) ;
131
+ inst ( '@test2@' ) ;
132
+ assert . deepStrictEqual ( messages , [ 'test2' ] ) ;
133
+ inst ( '@test3@' ) ;
134
+ assert . deepStrictEqual ( messages , [ 'test2' , 'test3' ] ) ;
135
+ debug . disable ( '*' ) ;
136
+ inst ( '@test4@' ) ;
137
+ assert . deepStrictEqual ( messages , [ 'test2' , 'test3' ] ) ;
138
+ } ) ;
120
139
} ) ;
121
140
} ) ;
You can’t perform that action at this time.
0 commit comments