Skip to content

Commit 6944d9d

Browse files
alan-agius4filipesilva
authored andcommitted
test(@angular-devkit/build-angular): update tests to use xxhash64
`loader-utils` version 3, introduced a breaking change with uses the faster `xxhash64` hashing algo.
1 parent 844ef76 commit 6944d9d

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

packages/angular_devkit/build_angular/src/builders/browser/specs/scripts-array_spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ describe('Browser Builder scripts array', () => {
8686
} as {});
8787

8888
const fileNames = Object.keys(files);
89-
const scriptsBundle = fileNames.find((n) => /scripts\.[0-9a-f]{20}\.js/.test(n));
89+
const scriptsBundle = fileNames.find((n) => /scripts\.[0-9a-f]{16}\.js/.test(n));
9090
expect(scriptsBundle).toBeTruthy();
9191
expect(await files[scriptsBundle || '']).toMatch('var number=2;');
9292

93-
expect(fileNames.some((n) => /scripts\.[0-9a-f]{20}\.js\.map/.test(n))).toBeTruthy();
94-
expect(fileNames.some((n) => /renamed-script\.[0-9a-f]{20}\.js/.test(n))).toBeTruthy();
95-
expect(fileNames.some((n) => /renamed-script\.[0-9a-f]{20}\.js\.map/.test(n))).toBeTruthy();
96-
expect(fileNames.some((n) => /script\.[0-9a-f]{20}\.js/.test(n))).toBeTruthy();
93+
expect(fileNames.some((n) => /scripts\.[0-9a-f]{16}\.js\.map/.test(n))).toBeTruthy();
94+
expect(fileNames.some((n) => /renamed-script\.[0-9a-f]{16}\.js/.test(n))).toBeTruthy();
95+
expect(fileNames.some((n) => /renamed-script\.[0-9a-f]{16}\.js\.map/.test(n))).toBeTruthy();
96+
expect(fileNames.some((n) => /script\.[0-9a-f]{16}\.js/.test(n))).toBeTruthy();
9797
expect(await files['lazy-script.js']).not.toBeUndefined();
9898
expect(await files['lazy-script.js.map']).not.toBeUndefined();
9999
expect(await files['renamed-lazy-script.js']).not.toBeUndefined();

packages/angular_devkit/build_angular/src/builders/browser/tests/options/output-hashing_spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
3535
expect(harness.hasFileMatch('dist', /main\.[0-9a-f]{16}\.js$/)).toBeTrue();
3636
expect(harness.hasFileMatch('dist', /polyfills\.[0-9a-f]{16}\.js$/)).toBeTrue();
3737
expect(harness.hasFileMatch('dist', /styles\.[0-9a-f]{16}\.css$/)).toBeTrue();
38-
expect(harness.hasFileMatch('dist', /spectrum\.[0-9a-f]{20}\.png$/)).toBeTrue();
38+
expect(harness.hasFileMatch('dist', /spectrum\.[0-9a-f]{16}\.png$/)).toBeTrue();
3939
});
4040

4141
it(`doesn't hash any filenames when not set`, async () => {
@@ -94,7 +94,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
9494
expect(harness.hasFileMatch('dist', /main\.[0-9a-f]{16}\.js$/)).toBeFalse();
9595
expect(harness.hasFileMatch('dist', /polyfills\.[0-9a-f]{16}\.js$/)).toBeFalse();
9696
expect(harness.hasFileMatch('dist', /styles\.[0-9a-f]{16}\.css$/)).toBeFalse();
97-
expect(harness.hasFileMatch('dist', /spectrum\.[0-9a-f]{20}\.png$/)).toBeTrue();
97+
expect(harness.hasFileMatch('dist', /spectrum\.[0-9a-f]{16}\.png$/)).toBeTrue();
9898
});
9999

100100
it(`hashes bundles filenames only when set to "bundles"`, async () => {

tests/legacy-cli/e2e/tests/build/output-hashing.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default async function () {
1717
await expectFileToMatch('dist/test-project/index.html', /runtime\.[0-9a-f]{16}\.js/);
1818
await expectFileToMatch('dist/test-project/index.html', /main\.[0-9a-f]{16}\.js/);
1919
await expectFileToMatch('dist/test-project/index.html', /styles\.[0-9a-f]{16}\.(css|js)/);
20-
await verifyMedia(/styles\.[0-9a-f]{16}\.(css|js)/, /image\.[0-9a-f]{20}\.png/);
20+
await verifyMedia(/styles\.[0-9a-f]{16}\.(css|js)/, /image\.[0-9a-f]{16}\.png/);
2121

2222
await ng('build', '--output-hashing=none', '--configuration=development');
2323
await expectFileToMatch('dist/test-project/index.html', /runtime\.js/);
@@ -29,7 +29,7 @@ export default async function () {
2929
await expectFileToMatch('dist/test-project/index.html', /runtime\.js/);
3030
await expectFileToMatch('dist/test-project/index.html', /main\.js/);
3131
await expectFileToMatch('dist/test-project/index.html', /styles\.(css|js)/);
32-
await verifyMedia(/styles\.(css|js)/, /image\.[0-9a-f]{20}\.png/);
32+
await verifyMedia(/styles\.(css|js)/, /image\.[0-9a-f]{16}\.png/);
3333

3434
await ng('build', '--output-hashing=bundles', '--configuration=development');
3535
await expectFileToMatch('dist/test-project/index.html', /runtime\.[0-9a-f]{16}\.js/);

0 commit comments

Comments
 (0)