Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #7 from andrew-codes/6-enable-preset
Enable presets
  • Loading branch information
andrew-codes committed Mar 2, 2019
2 parents bbe4934 + 65a4525 commit 813990f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/webhooked/src/index.js
@@ -1,7 +1,8 @@
module.exports = ({ plugins }) => {
module.exports = ({ plugins = [], presets = [] }) => {
return {
handle: async req => {
return plugins
return presets
.concat(plugins)
.map(pluginName => {
if (!Array.isArray(pluginName)) {
return {
Expand Down
11 changes: 11 additions & 0 deletions packages/webhooked/tests/index.test.js
Expand Up @@ -23,3 +23,14 @@ test('options can be provided which will be provided to plugins', async () => {

expect(testHandler2).toBeCalledWith(fakeRequest, options);
});

test('options can be bundled and applied as one or more preset', async () => {
const fakeRequest = { fake: 'request' };
const options = { someOption: 'value' };
await webhooked({
presets: ['../testing/testPlugin', ['../testing/testPlugin2', options]],
}).handle(fakeRequest);

expect(testHandler).toBeCalledWith(fakeRequest);
expect(testHandler2).toBeCalledWith(fakeRequest, options);
});

0 comments on commit 813990f

Please sign in to comment.