Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added merge multiple that outputs an array
- Loading branch information
Showing
3 changed files
with
128 additions
and
1 deletion.
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,114 @@ | ||
/* eslint-env mocha */ | ||
const assert = require('assert'); | ||
|
||
function multipleTests(merge) { | ||
it('should override objects', function () { | ||
const a = { | ||
client: { | ||
entry: './client.js' | ||
} | ||
}; | ||
const b = { | ||
client: { | ||
entry: './replaced.js' | ||
} | ||
}; | ||
const result = [ | ||
{ | ||
entry: './replaced.js' | ||
} | ||
]; | ||
|
||
assert.deepEqual(merge(a, b), result); | ||
}); | ||
|
||
it('should add new objects if not existing', function () { | ||
const a = { | ||
client: { | ||
entry: './client.js' | ||
}, | ||
server: { | ||
entry: './server.js', | ||
} | ||
}; | ||
const b = { | ||
client: { | ||
entry: './replaced.js' | ||
} | ||
}; | ||
const result = [ | ||
{ | ||
entry: './replaced.js' | ||
}, | ||
{ | ||
entry: './server.js' | ||
} | ||
]; | ||
|
||
assert.deepEqual(merge(a, b), result); | ||
}); | ||
|
||
it('should work with an array of objects', function () { | ||
const a = { | ||
client: { | ||
entry: ['./client.js', './client2.js'] | ||
}, | ||
server: { | ||
entry: ['./server.js', './server2.js'] | ||
} | ||
}; | ||
const b = { | ||
client: { | ||
entry: ['./replaced.js', './replaced2.js'] | ||
} | ||
}; | ||
const result = [ | ||
{ | ||
entry: ['./client.js', './client2.js', './replaced.js', './replaced2.js'] | ||
}, | ||
{ | ||
entry: ['./server.js', './server2.js'] | ||
} | ||
]; | ||
|
||
assert.deepEqual(merge(a, b), result); | ||
}); | ||
|
||
it('should deeply merge objects', function () { | ||
const a = { | ||
client: { | ||
entry: { | ||
main: './client.js' | ||
} | ||
}, | ||
server: { | ||
entry: { | ||
main: './server.js' | ||
} | ||
} | ||
}; | ||
const b = { | ||
client: { | ||
entry: { | ||
main: './replaced.js' | ||
} | ||
} | ||
}; | ||
const result = [ | ||
{ | ||
entry: { | ||
main: './replaced.js' | ||
} | ||
}, | ||
{ | ||
entry: { | ||
main: './server.js' | ||
} | ||
} | ||
]; | ||
|
||
assert.deepEqual(merge(a, b), result); | ||
}); | ||
} | ||
|
||
module.exports = multipleTests; |
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,10 @@ | ||
/* eslint-env mocha */ | ||
const webpackMerge = require('..'); | ||
const mergeMultipleTests = require('./merge-multiple-tests'); | ||
|
||
describe('Multiple merge', function () { | ||
const merge = webpackMerge.multiple; | ||
console.log(merge); | ||
|
||
mergeMultipleTests(merge); | ||
}); |