Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes opts passed to the BCU Plugin. #2017

Merged
merged 1 commit into from
Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions packages/workbox-build/src/lib/runtime-caching-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,8 @@ function getOptionsString(options = {}) {

case 'broadcastUpdate': {
const channelName = pluginConfig.channelName;
pluginCode = `new ${pluginString}(${JSON.stringify(channelName)}`;
if ('options' in pluginConfig) {
pluginCode += `, ${stringifyWithoutComments(pluginConfig.options)}`;
}
pluginCode += `)`;
const opts = Object.assign({channelName}, pluginConfig.options);
pluginCode = `new ${pluginString}(${stringifyWithoutComments(opts)})`;

break;
}
Expand Down
15 changes: 7 additions & 8 deletions test/workbox-build/node/lib/runtime-caching-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,14 @@ function validate(runtimeCachingOptions, convertedOptions) {

if (options.broadcastUpdate) {
if ('options' in options.broadcastUpdate) {
expect(
globalScope.workbox.broadcastUpdate.Plugin.calledWith(
options.broadcastUpdate.channelName, options.broadcastUpdate.options)
).to.be.true;
const expectedOptions = Object.assign(
{channelName: options.broadcastUpdate.channelName},
options.broadcastUpdate.options);
expect(globalScope.workbox.broadcastUpdate.Plugin.calledWith(expectedOptions))
.to.be.true;
} else {
expect(
globalScope.workbox.broadcastUpdate.Plugin.calledWith(
options.broadcastUpdate.channelName)
).to.be.true;
expect(globalScope.workbox.broadcastUpdate.Plugin.calledWith(
{channelName: options.broadcastUpdate.channelName})).to.be.true;
}
}
}
Expand Down