-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
107 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
*/ | ||
'use strict'; | ||
|
||
const setFromArgv = require('../setFromArgv'); | ||
|
||
test('maps special values to valid options', () => { | ||
const options = {}; | ||
const argv = { | ||
coverage: true, | ||
env: 'node', | ||
json: true, | ||
watchAll: true, | ||
}; | ||
|
||
expect(setFromArgv(options, argv)).toMatchObject({ | ||
collectCoverage: true, | ||
testEnvironment: 'node', | ||
useStderr: true, | ||
watch: true, | ||
}); | ||
}); | ||
|
||
test('maps regular values to themselves', () => { | ||
const options = {}; | ||
const argv = { | ||
collectCoverageOnlyFrom: ['a', 'b'], | ||
coverageDirectory: 'covDir', | ||
watchman: true, | ||
}; | ||
|
||
expect(setFromArgv(options, argv)).toMatchObject({ | ||
collectCoverageOnlyFrom: ['a', 'b'], | ||
coverageDirectory: 'covDir', | ||
watchman: true, | ||
}); | ||
}); | ||
|
||
test('works with string objects', () => { | ||
const options = {}; | ||
const argv = { | ||
moduleNameMapper: '{"types/(.*)": "<rootDir>/src/types/$1"}', | ||
transform: '{"*.js": "<rootDir>/transformer"}', | ||
}; | ||
expect(setFromArgv(options, argv)).toMatchObject({ | ||
moduleNameMapper: { | ||
'types/(.*)': '<rootDir>/src/types/$1', | ||
}, | ||
transform: { | ||
'*.js': '<rootDir>/transformer', | ||
}, | ||
}); | ||
}); | ||
|
||
test('--config overrides all', () => { | ||
const options = {}; | ||
const argv = { | ||
config: '{"watch": true}', | ||
watch: false, | ||
}; | ||
expect(setFromArgv(options, argv)).toMatchObject({watch: true}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters