Skip to content

Commit

Permalink
Merge pull request #15010 from webpack/test/large-cache-file
Browse files Browse the repository at this point in the history
improve test case to check correct data
  • Loading branch information
sokra committed Jan 10, 2022
2 parents 5929bfc + 9fa7eba commit 016ec7b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/cases/large/big-assets/generate-big-asset-loader.js
@@ -1,6 +1,6 @@
/** @type {import("../../../../").RawLoaderDefinition<{ size: string }>} */
module.exports = function () {
const options = this.getOptions();
return Buffer.alloc(+options.size);
return Buffer.alloc(+options.size).fill(0xa5);
};
module.exports.raw = true;
15 changes: 15 additions & 0 deletions test/cases/large/big-assets/index.js
@@ -1,3 +1,12 @@
const createHash = require("../../../../lib/util/hash/xxhash64");
const fs = require("fs");

const h = url => {
const hash = createHash();
hash.update(fs.readFileSync(url));
return hash.digest("hex");
};

it("should compile fine", () => {
const a = new URL(
"./generate-big-asset-loader.js?size=100000000!",
Expand All @@ -23,4 +32,10 @@ it("should compile fine", () => {
"./generate-big-asset-loader.js?size=600000000!",
import.meta.url
);
expect(h(a)).toBe("a7540f59366bb641");
expect(h(b)).toBe("f642344242fa9de4");
expect(h(c)).toBe("255d2b78f94dd585");
expect(h(d)).toBe("c75503096358dd24");
expect(h(e)).toBe("33ba203498301384");
expect(h(f)).toBe("e71a39b9b1138c07");
});

0 comments on commit 016ec7b

Please sign in to comment.