File tree 2 files changed +25
-0
lines changed
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ function option({
32
32
: defaultValue ;
33
33
} else if ( ! isDeprecated ) {
34
34
throw new MissingOptionError ( locator . name ) ;
35
+ } else {
36
+ isSetByUser = false ;
35
37
}
36
38
37
39
if ( isSetByUser && isDeprecated ) {
Original file line number Diff line number Diff line change
1
+ const sinon = require ( 'sinon' ) ;
1
2
const { option} = require ( '../lib/core' ) ;
2
3
const { MissingOptionError} = require ( '../lib/errors' ) ;
3
4
4
5
describe ( 'option' , ( ) => {
6
+ let consoleWarnStub ;
7
+
8
+ beforeEach ( ( ) => {
9
+ consoleWarnStub = sinon . stub ( console , 'warn' ) ;
10
+ } ) ;
11
+
12
+ afterEach ( ( ) => {
13
+ consoleWarnStub . restore ( ) ;
14
+ } ) ;
15
+
5
16
const LAZY_CONFIG = {
6
17
root : { defaultKey : 'defaultValue' }
7
18
} ;
@@ -155,6 +166,18 @@ describe('option', () => {
155
166
const parser = option ( { isDeprecated : true } ) ;
156
167
assert . doesNotThrow ( ( ) => parser ( { } , LAZY_CONFIG ) , MissingOptionError ) ;
157
168
} ) ;
169
+
170
+ it ( 'should not log warning on deprecated option without any value' , ( ) => {
171
+ option ( { isDeprecated : true } ) ( { } , LAZY_CONFIG ) ;
172
+
173
+ assert . notCalled ( consoleWarnStub ) ;
174
+ } ) ;
175
+ } ) ;
176
+
177
+ it ( 'should log warning on deprecated option if option is set' , ( ) => {
178
+ option ( { isDeprecated : true } ) ( { envVar : 'foo' } , LAZY_CONFIG ) ;
179
+
180
+ assert . calledWith ( consoleWarnStub , sinon . match ( 'option is deprecated' ) ) ;
158
181
} ) ;
159
182
160
183
function testAfterParseCallback ( name ) {
You can’t perform that action at this time.
0 commit comments