Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Commit

Permalink
test: add publicPath handler returning a function test
Browse files Browse the repository at this point in the history
  • Loading branch information
prontiol committed Apr 23, 2019
1 parent dd12c83 commit 6a69663
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/__snapshots__/publicPath-option.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ Object {
}
`;

exports[`when applied with \`publicPath\` option matches snapshot for \`{Function}\` value returning {Function} 1`] = `
Object {
"assets": Array [
"9c87cbf3ba33126ffd25ae7f2f6bbafb.png",
],
"source": "module.exports = (function (url) {
return window.customPublicPath + url;
})(\\"9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\");",
}
`;

exports[`when applied with \`publicPath\` option matches snapshot for \`{String}\` value 1`] = `
Object {
"assets": Array [
Expand Down
22 changes: 22 additions & 0 deletions test/publicPath-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,26 @@ describe('when applied with `publicPath` option', () => {

expect({ assets, source }).toMatchSnapshot();
});

it('matches snapshot for `{Function}` value returning {Function}', async () => {
const config = {
loader: {
test: /(png|jpg|svg)/,
options: {
publicPath() {
return function publicPath(url) {
// eslint-disable-next-line no-undef
return window.customPublicPath + url;
};
},
},
},
};

const stats = await webpack('fixture.js', config);
const [module] = stats.toJson().modules;
const { assets, source } = module;

expect({ assets, source }).toMatchSnapshot();
});
});

0 comments on commit 6a69663

Please sign in to comment.