Skip to content

Commit

Permalink
update test snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
koddsson committed Nov 13, 2023
1 parent 7ac2af6 commit d8142f0
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ describe('@rollup/plugin-commonjs', () => {
try {
const text = await fetchText(`${host}/foo.js`);
expectIncludes(text, 'var foo = "foo";');
expectIncludes(text, 'export default /*@__PURE__*/commonjsHelpers.getDefaultExportFromCjs(foo)');
expectIncludes(
text,
'export default /*@__PURE__*/commonjsHelpers.getDefaultExportFromCjs(foo)',
);
} finally {
server.stop();
}
Expand Down
70 changes: 35 additions & 35 deletions packages/rollup-plugin-import-meta-assets/test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ describe('rollup-plugin-import-meta-assets', () => {

expect(output.length).to.equal(6);
expectChunk(output, 'snapshots/simple-bundle.js', 'simple-bundle.js', [
expectAsset(output, 'snapshots/one.svg', 'one.svg', 'assets/one-824f522a.svg'),
expectAsset(output, 'snapshots/two.svg', 'two.svg', 'assets/two-efaa9ab3.svg'),
expectAsset(output, 'snapshots/three.svg', 'three.svg', 'assets/three-63bfb103.svg'),
expectAsset(output, 'snapshots/four.svg', 'four.svg', 'assets/four-360cc920.svg'),
expectAsset(output, 'snapshots/five', 'five', 'assets/five-cd1ca868'),
expectAsset(output, 'snapshots/one.svg', 'one.svg', 'assets/one-ZInu4dBJ.svg'),
expectAsset(output, 'snapshots/two.svg', 'two.svg', 'assets/two--yckvrYd.svg'),
expectAsset(output, 'snapshots/three.svg', 'three.svg', 'assets/three-CDdgprDC.svg'),
expectAsset(output, 'snapshots/four.svg', 'four.svg', 'assets/four-lJVunLww.svg'),
expectAsset(output, 'snapshots/five', 'five', 'assets/five-Z74_0e9C'),
]);
});

Expand All @@ -80,11 +80,11 @@ describe('rollup-plugin-import-meta-assets', () => {

expect(output.length).to.equal(6);
expectChunk(output, 'snapshots/transform-bundle.js', 'transform-bundle.js', [
expectAsset(output, 'snapshots/one.min.svg', 'one.svg', 'assets/one-2d604b7f.svg'),
expectAsset(output, 'snapshots/two.min.svg', 'two.svg', 'assets/two-4f4a5196.svg'),
expectAsset(output, 'snapshots/three.min.svg', 'three.svg', 'assets/three-cb83a3f2.svg'),
expectAsset(output, 'snapshots/four.min.svg', 'four.svg', 'assets/four-97848687.svg'),
expectAsset(output, 'snapshots/image.jpg', 'image.jpg', 'assets/image-c160fa1b.jpg'),
expectAsset(output, 'snapshots/one.min.svg', 'one.svg', 'assets/one-PkYUFgN1.svg'),
expectAsset(output, 'snapshots/two.min.svg', 'two.svg', 'assets/two-mXcSFMIh.svg'),
expectAsset(output, 'snapshots/three.min.svg', 'three.svg', 'assets/three-LRYckR_0.svg'),
expectAsset(output, 'snapshots/four.min.svg', 'four.svg', 'assets/four-rNTiHfqi.svg'),
expectAsset(output, 'snapshots/image.jpg', 'image.jpg', 'assets/image-vdjfMj42.jpg'),
]);
});

Expand All @@ -109,10 +109,10 @@ describe('rollup-plugin-import-meta-assets', () => {

expect(output.length).to.equal(5);
expectChunk(output, 'snapshots/transform-bundle-ignored.js', 'transform-bundle-ignored.js', [
expectAsset(output, 'snapshots/one.min.svg', 'one.svg', 'assets/one-2d604b7f.svg'),
expectAsset(output, 'snapshots/two.min.svg', 'two.svg', 'assets/two-4f4a5196.svg'),
expectAsset(output, 'snapshots/three.min.svg', 'three.svg', 'assets/three-cb83a3f2.svg'),
expectAsset(output, 'snapshots/four.min.svg', 'four.svg', 'assets/four-97848687.svg'),
expectAsset(output, 'snapshots/one.min.svg', 'one.svg', 'assets/one-PkYUFgN1.svg'),
expectAsset(output, 'snapshots/two.min.svg', 'two.svg', 'assets/two-mXcSFMIh.svg'),
expectAsset(output, 'snapshots/three.min.svg', 'three.svg', 'assets/three-LRYckR_0.svg'),
expectAsset(output, 'snapshots/four.min.svg', 'four.svg', 'assets/four-rNTiHfqi.svg'),
]);
});

Expand All @@ -127,10 +127,10 @@ describe('rollup-plugin-import-meta-assets', () => {

expect(output.length).to.equal(5);
expectChunk(output, 'snapshots/multi-level-bundle.js', 'multi-level-bundle.js', [
expectAsset(output, 'snapshots/one.svg', 'one.svg', 'assets/one-824f522a.svg'),
expectAsset(output, 'snapshots/two.svg', 'two.svg', 'assets/two-efaa9ab3.svg'),
expectAsset(output, 'snapshots/three.svg', 'three.svg', 'assets/three-63bfb103.svg'),
expectAsset(output, 'snapshots/four.svg', 'four.svg', 'assets/four-360cc920.svg'),
expectAsset(output, 'snapshots/one.svg', 'one.svg', 'assets/one-ZInu4dBJ.svg'),
expectAsset(output, 'snapshots/two.svg', 'two.svg', 'assets/two--yckvrYd.svg'),
expectAsset(output, 'snapshots/three.svg', 'three.svg', 'assets/three-CDdgprDC.svg'),
expectAsset(output, 'snapshots/four.svg', 'four.svg', 'assets/four-lJVunLww.svg'),
]);
});

Expand All @@ -149,10 +149,10 @@ describe('rollup-plugin-import-meta-assets', () => {

expect(output.length).to.equal(5);
expectChunk(output, 'snapshots/multi-level-bundle.js', 'multi-level-bundle.js', [
expectAsset(output, 'snapshots/one.svg', 'one.svg', 'assets/one-824f522a.svg'),
expectAsset(output, 'snapshots/two.svg', 'two.svg', 'assets/two-efaa9ab3.svg'),
expectAsset(output, 'snapshots/three.svg', 'three.svg', 'assets/three-63bfb103.svg'),
expectAsset(output, 'snapshots/four.svg', 'four.svg', 'assets/four-360cc920.svg'),
expectAsset(output, 'snapshots/one.svg', 'one.svg', 'assets/one-ZInu4dBJ.svg'),
expectAsset(output, 'snapshots/two.svg', 'two.svg', 'assets/two--yckvrYd.svg'),
expectAsset(output, 'snapshots/three.svg', 'three.svg', 'assets/three-CDdgprDC.svg'),
expectAsset(output, 'snapshots/four.svg', 'four.svg', 'assets/four-lJVunLww.svg'),
]);
});

Expand All @@ -175,15 +175,15 @@ describe('rollup-plugin-import-meta-assets', () => {
'snapshots/different-asset-levels-bundle.js',
'different-asset-levels-bundle.js',
[
expectAsset(output, 'snapshots/one.svg', 'one-deep.svg', 'assets/one-deep-824f522a.svg'),
expectAsset(output, 'snapshots/two.svg', 'two-deep.svg', 'assets/two-deep-efaa9ab3.svg'),
expectAsset(output, 'snapshots/one.svg', 'one-deep.svg', 'assets/one-deep-ZInu4dBJ.svg'),
expectAsset(output, 'snapshots/two.svg', 'two-deep.svg', 'assets/two-deep--yckvrYd.svg'),
expectAsset(
output,
'snapshots/three.svg',
'three-deep.svg',
'assets/three-deep-63bfb103.svg',
'assets/three-deep-CDdgprDC.svg',
),
expectAsset(output, 'snapshots/four.svg', 'four-deep.svg', 'assets/four-deep-360cc920.svg'),
expectAsset(output, 'snapshots/four.svg', 'four-deep.svg', 'assets/four-deep-lJVunLww.svg'),
],
);
});
Expand Down Expand Up @@ -215,10 +215,10 @@ describe('rollup-plugin-import-meta-assets', () => {
expectChunk(output, 'snapshots/one-bundle.js', 'one-bundle.js', []);
expectChunk(output, 'snapshots/two-bundle.js', 'two-bundle.js', []);
expectChunk(output, 'snapshots/three-bundle.js', 'three-bundle.js', [
expectAsset(output, 'snapshots/three.svg', 'three.svg', 'assets/three-63bfb103.svg'),
expectAsset(output, 'snapshots/three.svg', 'three.svg', 'assets/three-CDdgprDC.svg'),
]);
expectChunk(output, 'snapshots/four-bundle.js', 'four-bundle.js', [
expectAsset(output, 'snapshots/four.svg', 'four.svg', 'assets/four-360cc920.svg'),
expectAsset(output, 'snapshots/four.svg', 'four.svg', 'assets/four-lJVunLww.svg'),
]);
});

Expand Down Expand Up @@ -269,9 +269,9 @@ describe('rollup-plugin-import-meta-assets', () => {

expect(output.length).to.equal(4);
expectChunk(output, 'snapshots/dynamic-vars.js', 'dynamic-vars.js', [
expectAsset(output, 'snapshots/three.svg', 'three.svg', 'assets/three-63bfb103.svg'),
expectAsset(output, 'snapshots/two.svg', 'two.svg', 'assets/two-efaa9ab3.svg'),
expectAsset(output, 'snapshots/one.svg', 'one.svg', 'assets/one-824f522a.svg'),
expectAsset(output, 'snapshots/three.svg', 'three.svg', 'assets/three-CDdgprDC.svg'),
expectAsset(output, 'snapshots/two.svg', 'two.svg', 'assets/two--yckvrYd.svg'),
expectAsset(output, 'snapshots/one.svg', 'one.svg', 'assets/one-ZInu4dBJ.svg'),
]);
});

Expand All @@ -288,10 +288,10 @@ describe('rollup-plugin-import-meta-assets', () => {

expect(output.length).to.equal(5);
expectChunk(output, 'snapshots/directories-ignored.js', 'directories-ignored.js', [
expectAsset(output, 'snapshots/one.svg', 'one.svg', 'assets/one-824f522a.svg'),
expectAsset(output, 'snapshots/two.svg', 'two.svg', 'assets/two-efaa9ab3.svg'),
expectAsset(output, 'snapshots/three.svg', 'three.svg', 'assets/three-63bfb103.svg'),
expectAsset(output, 'snapshots/four.svg', 'four.svg', 'assets/four-360cc920.svg'),
expectAsset(output, 'snapshots/one.svg', 'one.svg', 'assets/one-ZInu4dBJ.svg'),
expectAsset(output, 'snapshots/two.svg', 'two.svg', 'assets/two--yckvrYd.svg'),
expectAsset(output, 'snapshots/three.svg', 'three.svg', 'assets/three-CDdgprDC.svg'),
expectAsset(output, 'snapshots/four.svg', 'four.svg', 'assets/four-lJVunLww.svg'),
]);
});
});
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const nameOne = 'one-name';
const imageOne = new URL(new URL('assets/one-deep-824f522a.svg', import.meta.url).href, import.meta.url).href;
const imageOne = new URL(new URL('assets/one-deep-ZInu4dBJ.svg', import.meta.url).href, import.meta.url).href;

const nameTwo = 'two-name';
const imageTwo = new URL(new URL('assets/two-deep-efaa9ab3.svg', import.meta.url).href, import.meta.url).href;
const imageTwo = new URL(new URL('assets/two-deep--yckvrYd.svg', import.meta.url).href, import.meta.url).href;

const nameThree = 'three-name';
const imageThree = new URL(new URL('assets/three-deep-63bfb103.svg', import.meta.url).href, import.meta.url).href;
const imageThree = new URL(new URL('assets/three-deep-CDdgprDC.svg', import.meta.url).href, import.meta.url).href;

const nameFour = 'four-name';
const imageFour = new URL(new URL('assets/four-deep-360cc920.svg', import.meta.url).href, import.meta.url).href;
const imageFour = new URL(new URL('assets/four-deep-lJVunLww.svg', import.meta.url).href, import.meta.url).href;

console.log({
[nameOne]: imageOne,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const justUrlObject = new URL(new URL('assets/one-824f522a.svg', import.meta.url).href, import.meta.url);
const href = new URL(new URL('assets/two-efaa9ab3.svg', import.meta.url).href, import.meta.url).href;
const pathname = new URL(new URL('assets/three-63bfb103.svg', import.meta.url).href, import.meta.url).pathname;
const searchParams = new URL(new URL('assets/four-360cc920.svg', import.meta.url).href, import.meta.url).searchParams;
const justUrlObject = new URL(new URL('assets/one-ZInu4dBJ.svg', import.meta.url).href, import.meta.url);
const href = new URL(new URL('assets/two--yckvrYd.svg', import.meta.url).href, import.meta.url).href;
const pathname = new URL(new URL('assets/three-CDdgprDC.svg', import.meta.url).href, import.meta.url).pathname;
const searchParams = new URL(new URL('assets/four-lJVunLww.svg', import.meta.url).href, import.meta.url).searchParams;

const directories = [
new URL('./', import.meta.url),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function __variableDynamicURLRuntime0__(path) {
switch (path) {
case './dynamic-assets/one.svg': return new URL(new URL('assets/one-824f522a.svg', import.meta.url).href, import.meta.url);
case './dynamic-assets/three.svg': return new URL(new URL('assets/three-63bfb103.svg', import.meta.url).href, import.meta.url);
case './dynamic-assets/two.svg': return new URL(new URL('assets/two-efaa9ab3.svg', import.meta.url).href, import.meta.url);
case './dynamic-assets/one.svg': return new URL(new URL('assets/one-ZInu4dBJ.svg', import.meta.url).href, import.meta.url);
case './dynamic-assets/three.svg': return new URL(new URL('assets/three-CDdgprDC.svg', import.meta.url).href, import.meta.url);
case './dynamic-assets/two.svg': return new URL(new URL('assets/two--yckvrYd.svg', import.meta.url).href, import.meta.url);
default: return new Promise(function(resolve, reject) {
(typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)(
reject.bind(null, new Error("Unknown variable dynamic new URL statement: " + path))
Expand All @@ -16,6 +16,6 @@ const names = ['one', 'two'];
// Therefore, we expect both one.svg, two.svg and three.svg to be bundled, and this to turn into a switch statement
// with 3 cases (for all 3 assets in the dynamic-assets folder)
const dynamicImgs = names.map(n => __variableDynamicURLRuntime0__(`./dynamic-assets/${n}.svg`));
const backticksImg = new URL(new URL('assets/three-63bfb103.svg', import.meta.url).href, import.meta.url);
const backticksImg = new URL(new URL('assets/three-CDdgprDC.svg', import.meta.url).href, import.meta.url);

console.log(dynamicImgs, backticksImg);
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const nameFour = 'four-name';
const imageFour = new URL(new URL('assets/four-360cc920.svg', import.meta.url).href, import.meta.url).href;
const imageFour = new URL(new URL('assets/four-lJVunLww.svg', import.meta.url).href, import.meta.url).href;

export { imageFour, nameFour };
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const nameOne = 'one-name';
const imageOne = new URL(new URL('assets/one-824f522a.svg', import.meta.url).href, import.meta.url).href;
const imageOne = new URL(new URL('assets/one-ZInu4dBJ.svg', import.meta.url).href, import.meta.url).href;

const nameTwo = 'two-name';
const imageTwo = new URL(new URL('assets/two-efaa9ab3.svg', import.meta.url).href, import.meta.url).href;
const imageTwo = new URL(new URL('assets/two--yckvrYd.svg', import.meta.url).href, import.meta.url).href;

const nameThree = 'three-name';
const imageThree = new URL(new URL('assets/three-63bfb103.svg', import.meta.url).href, import.meta.url).href;
const imageThree = new URL(new URL('assets/three-CDdgprDC.svg', import.meta.url).href, import.meta.url).href;

const nameFour = 'four-name';
const imageFour = new URL(new URL('assets/four-360cc920.svg', import.meta.url).href, import.meta.url).href;
const imageFour = new URL(new URL('assets/four-lJVunLww.svg', import.meta.url).href, import.meta.url).href;

console.log({
[nameOne]: imageOne,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const justUrlObject = new URL(new URL('assets/one-824f522a.svg', import.meta.url).href, import.meta.url);
const href = new URL(new URL('assets/two-efaa9ab3.svg', import.meta.url).href, import.meta.url).href;
const pathname = new URL(new URL('assets/three-63bfb103.svg', import.meta.url).href, import.meta.url).pathname;
const searchParams = new URL(new URL('assets/four-360cc920.svg', import.meta.url).href, import.meta.url).searchParams;
const noExtension = new URL(new URL('assets/five-cd1ca868', import.meta.url).href, import.meta.url);
const justUrlObject = new URL(new URL('assets/one-ZInu4dBJ.svg', import.meta.url).href, import.meta.url);
const href = new URL(new URL('assets/two--yckvrYd.svg', import.meta.url).href, import.meta.url).href;
const pathname = new URL(new URL('assets/three-CDdgprDC.svg', import.meta.url).href, import.meta.url).pathname;
const searchParams = new URL(new URL('assets/four-lJVunLww.svg', import.meta.url).href, import.meta.url).searchParams;
const noExtension = new URL(new URL('assets/five-Z74_0e9C', import.meta.url).href, import.meta.url);

console.log({
justUrlObject,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const nameThree = 'three-name';
const imageThree = new URL(new URL('assets/three-63bfb103.svg', import.meta.url).href, import.meta.url).href;
const imageThree = new URL(new URL('assets/three-CDdgprDC.svg', import.meta.url).href, import.meta.url).href;

export { imageThree, nameThree };
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const justUrlObject = new URL(new URL('assets/one-2d604b7f.svg', import.meta.url).href, import.meta.url);
const href = new URL(new URL('assets/two-4f4a5196.svg', import.meta.url).href, import.meta.url).href;
const pathname = new URL(new URL('assets/three-cb83a3f2.svg', import.meta.url).href, import.meta.url).pathname;
const searchParams = new URL(new URL('assets/four-97848687.svg', import.meta.url).href, import.meta.url).searchParams;
const justUrlObject = new URL(new URL('assets/one-PkYUFgN1.svg', import.meta.url).href, import.meta.url);
const href = new URL(new URL('assets/two-mXcSFMIh.svg', import.meta.url).href, import.meta.url).href;
const pathname = new URL(new URL('assets/three-LRYckR_0.svg', import.meta.url).href, import.meta.url).pathname;
const searchParams = new URL(new URL('assets/four-rNTiHfqi.svg', import.meta.url).href, import.meta.url).searchParams;
const someJpg = new URL('./image.jpg', import.meta.url);

console.log({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const justUrlObject = new URL(new URL('assets/one-2d604b7f.svg', import.meta.url).href, import.meta.url);
const href = new URL(new URL('assets/two-4f4a5196.svg', import.meta.url).href, import.meta.url).href;
const pathname = new URL(new URL('assets/three-cb83a3f2.svg', import.meta.url).href, import.meta.url).pathname;
const searchParams = new URL(new URL('assets/four-97848687.svg', import.meta.url).href, import.meta.url).searchParams;
const someJpg = new URL(new URL('assets/image-c160fa1b.jpg', import.meta.url).href, import.meta.url);
const justUrlObject = new URL(new URL('assets/one-PkYUFgN1.svg', import.meta.url).href, import.meta.url);
const href = new URL(new URL('assets/two-mXcSFMIh.svg', import.meta.url).href, import.meta.url).href;
const pathname = new URL(new URL('assets/three-LRYckR_0.svg', import.meta.url).href, import.meta.url).pathname;
const searchParams = new URL(new URL('assets/four-rNTiHfqi.svg', import.meta.url).href, import.meta.url).searchParams;
const someJpg = new URL(new URL('assets/image-vdjfMj42.jpg', import.meta.url).href, import.meta.url);

console.log({
justUrlObject,
Expand Down

0 comments on commit d8142f0

Please sign in to comment.