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

Commit 6e22f6e

Browse files
authoredAug 31, 2020
test: fix
1 parent 40fcde8 commit 6e22f6e

File tree

5 files changed

+1985
-2537
lines changed

5 files changed

+1985
-2537
lines changed
 

‎.github/workflows/nodejs.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ jobs:
4343
- name: Lint
4444
run: npm run lint
4545

46-
# - name: Security audit
47-
# run: npm run security
46+
- name: Security audit
47+
run: npm run security
4848

4949
- name: Check commit message
5050
uses: wagoid/commitlint-github-action@v1

‎package-lock.json

+1,932-2,508
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+14-14
Original file line numberDiff line numberDiff line change
@@ -42,32 +42,32 @@
4242
},
4343
"dependencies": {
4444
"loader-utils": "^2.0.0",
45-
"schema-utils": "^2.7.0"
45+
"schema-utils": "^2.7.1"
4646
},
4747
"devDependencies": {
48-
"@babel/cli": "^7.10.3",
49-
"@babel/core": "^7.10.3",
50-
"@babel/preset-env": "^7.10.3",
51-
"@commitlint/cli": "^9.0.1",
52-
"@commitlint/config-conventional": "^9.0.1",
48+
"@babel/cli": "^7.10.5",
49+
"@babel/core": "^7.11.4",
50+
"@babel/preset-env": "^7.11.0",
51+
"@commitlint/cli": "^10.0.0",
52+
"@commitlint/config-conventional": "^10.0.0",
5353
"@webpack-contrib/defaults": "^6.3.0",
5454
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
55-
"babel-jest": "^26.0.1",
55+
"babel-jest": "^26.3.0",
5656
"cross-env": "^7.0.2",
5757
"del": "^5.1.0",
5858
"del-cli": "^3.0.1",
59-
"eslint": "^7.3.0",
59+
"eslint": "^7.7.0",
6060
"eslint-config-prettier": "^6.11.0",
61-
"eslint-plugin-import": "^2.21.2",
61+
"eslint-plugin-import": "^2.22.0",
6262
"husky": "^4.2.5",
63-
"jest": "^26.0.1",
64-
"lint-staged": "^10.2.11",
63+
"jest": "^26.4.2",
64+
"lint-staged": "^10.2.13",
6565
"memfs": "^3.2.0",
6666
"npm-run-all": "^4.1.5",
67-
"prettier": "^2.0.5",
68-
"standard-version": "^8.0.0",
67+
"prettier": "^2.1.1",
68+
"standard-version": "^9.0.0",
6969
"url-loader": "^4.1.0",
70-
"webpack": "^4.43.0"
70+
"webpack": "^4.44.1"
7171
},
7272
"keywords": [
7373
"webpack"

‎test/loader.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ describe('loader', () => {
112112
expect(normalizeErrors(stats.compilation.errors)).toMatchSnapshot('errors');
113113

114114
if (stats.compilation.modules.size) {
115-
expect(stats.compilation.modules.size).toBe(2);
115+
expect(stats.compilation.modules.size).toBe(3);
116116
} else {
117117
expect(stats.compilation.modules.length).toBe(1);
118118
}

‎test/name-option.test.js

+36-12
Original file line numberDiff line numberDiff line change
@@ -83,37 +83,61 @@ describe('"name" option', () => {
8383
expect(normalizeErrors(stats.compilation.errors)).toMatchSnapshot('errors');
8484
});
8585

86-
it('should mark hashed asset as immutable', async () => {
86+
it('should work and emit "immutable" for assets flag by default', async () => {
87+
expect.assertions(1);
88+
89+
const compiler = getCompiler('simple.js');
90+
const stats = await compile(compiler);
91+
92+
for (const [name, info] of stats.compilation.assetsInfo) {
93+
if (name.endsWith('png')) {
94+
expect(info.immutable).toBe(true);
95+
}
96+
}
97+
});
98+
99+
it('should work and emit "immutable" for hashed assets', async () => {
100+
expect.assertions(1);
101+
87102
const compiler = getCompiler('simple.js', {
88103
name: '[md5:hash:hex:8].asset.[ext]',
89104
});
90105
const stats = await compile(compiler);
91106

92-
let assetInfo;
93107
for (const [name, info] of stats.compilation.assetsInfo) {
94-
if (name.match('asset.')) {
95-
assetInfo = info;
96-
break;
108+
if (name.endsWith('png')) {
109+
expect(info.immutable).toBe(true);
97110
}
98111
}
112+
});
99113

100-
expect(assetInfo.immutable).toBe(true);
114+
it('should work and emit "immutable" for hashed assets #2', async () => {
115+
expect.assertions(1);
116+
117+
const compiler = getCompiler('simple.js', {
118+
name: '[name].[contenthash].asset.[ext]',
119+
});
120+
const stats = await compile(compiler);
121+
122+
for (const [name, info] of stats.compilation.assetsInfo) {
123+
if (name.endsWith('png')) {
124+
expect(info.immutable).toBe(true);
125+
}
126+
}
101127
});
102128

103129
it('should not mark unhashed asset as immutable', async () => {
130+
expect.assertions(1);
131+
104132
const compiler = getCompiler('simple.js', {
105133
name: 'asset.[ext]',
106134
});
107135
const stats = await compile(compiler);
108136

109-
let assetInfo;
110137
for (const [name, info] of stats.compilation.assetsInfo) {
111-
if (name.match('asset.')) {
112-
assetInfo = info;
113-
break;
138+
if (name.endsWith('png')) {
139+
expect(info.immutable).toBe(false);
114140
}
115141
}
116-
117-
expect(assetInfo.immutable).toBe(false);
118142
});
119143
});

0 commit comments

Comments
 (0)
This repository has been archived.