-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
17cbb36
commit 4e56826
Showing
5 changed files
with
99 additions
and
6 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,13 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
const { mergeWith } = require('lodash'); | ||
|
||
function mergeArrays(dest, src) { | ||
if (Array.isArray(dest)) { | ||
return dest.concat(src); | ||
} | ||
} | ||
|
||
module.exports = function mergePresets(...presets) { | ||
return mergeWith({}, ...presets, mergeArrays); | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,79 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
const tap = require('tap'); | ||
const { strict: assert } = require('assert'); | ||
const merge = require('../merge'); | ||
|
||
tap.test('merging simple configurations', t => { | ||
assert.deepEqual( | ||
merge( | ||
{ | ||
transformIgnorePatterns: ['project-ignore'], | ||
transform: { | ||
'project-js': 'project-babel-jest', | ||
}, | ||
}, | ||
{ | ||
transformIgnorePatterns: ['our-ignore'], | ||
transform: { | ||
'cloudscape-js': 'our-babel-jest', | ||
}, | ||
}, | ||
), | ||
{ | ||
transform: { | ||
'project-js': 'project-babel-jest', | ||
'cloudscape-js': 'our-babel-jest', | ||
}, | ||
transformIgnorePatterns: ['project-ignore', 'our-ignore'], | ||
}, | ||
); | ||
t.end(); | ||
}); | ||
|
||
tap.test('merging multiple configurations', t => { | ||
assert.deepEqual( | ||
merge( | ||
{ | ||
transform: { 'project-js': 'project-babel-jest' }, | ||
}, | ||
{ | ||
transform: { 'project-ts': 'ts-transformer' }, | ||
}, | ||
|
||
{ | ||
transform: { 'cloudscape-js': 'our-babel-jest' }, | ||
}, | ||
), | ||
{ | ||
transform: { | ||
'project-js': 'project-babel-jest', | ||
'project-ts': 'ts-transformer', | ||
'cloudscape-js': 'our-babel-jest', | ||
}, | ||
}, | ||
); | ||
t.end(); | ||
}); | ||
|
||
tap.test('does not mutate objects', t => { | ||
const src = { | ||
transform: { 'project-js': 'project-babel-jest' }, | ||
}; | ||
const dest = { | ||
transform: { 'cloudscape-js': 'our-babel-jest' }, | ||
}; | ||
assert.deepEqual(merge(src, dest), { | ||
transform: { | ||
'project-js': 'project-babel-jest', | ||
'cloudscape-js': 'our-babel-jest', | ||
}, | ||
}); | ||
assert.deepEqual(src, { | ||
transform: { 'project-js': 'project-babel-jest' }, | ||
}); | ||
assert.deepEqual(dest, { | ||
transform: { 'cloudscape-js': 'our-babel-jest' }, | ||
}); | ||
t.end(); | ||
}); |