@@ -90,7 +90,7 @@ describe('"name" option', () => {
90
90
const stats = await compile ( compiler ) ;
91
91
92
92
for ( const [ name , info ] of stats . compilation . assetsInfo ) {
93
- if ( name . endsWith ( 'png' ) ) {
93
+ if ( name . endsWith ( '. png' ) ) {
94
94
expect ( info . immutable ) . toBe ( true ) ;
95
95
}
96
96
}
@@ -105,7 +105,7 @@ describe('"name" option', () => {
105
105
const stats = await compile ( compiler ) ;
106
106
107
107
for ( const [ name , info ] of stats . compilation . assetsInfo ) {
108
- if ( name . endsWith ( 'png' ) ) {
108
+ if ( name . endsWith ( '. png' ) ) {
109
109
expect ( info . immutable ) . toBe ( true ) ;
110
110
}
111
111
}
@@ -120,13 +120,29 @@ describe('"name" option', () => {
120
120
const stats = await compile ( compiler ) ;
121
121
122
122
for ( const [ name , info ] of stats . compilation . assetsInfo ) {
123
- if ( name . endsWith ( ' png') ) {
123
+ if ( name . startsWith ( 'file.39f5c21c1aee6ff21844c6e1d8251d97.asset. png') ) {
124
124
expect ( info . immutable ) . toBe ( true ) ;
125
125
}
126
126
}
127
127
} ) ;
128
128
129
- it ( 'should not mark unhashed asset as immutable' , async ( ) => {
129
+ it ( 'should work and emit "immutable" for hashed assets #3' , async ( ) => {
130
+ expect . assertions ( 1 ) ;
131
+
132
+ const compiler = getCompiler ( 'simple.js' , {
133
+ name : '[name].asset.[ext]?foo=[contenthash]' ,
134
+ } ) ;
135
+ const stats = await compile ( compiler ) ;
136
+
137
+ for ( const [ name , info ] of stats . compilation . assetsInfo ) {
138
+ if ( name . startsWith ( 'file.asset.png' ) ) {
139
+ // eslint-disable-next-line no-undefined
140
+ expect ( info . immutable ) . toBe ( undefined ) ;
141
+ }
142
+ }
143
+ } ) ;
144
+
145
+ it ( 'should work and not emit "immutable" for not hashed assets' , async ( ) => {
130
146
expect . assertions ( 1 ) ;
131
147
132
148
const compiler = getCompiler ( 'simple.js' , {
@@ -135,8 +151,9 @@ describe('"name" option', () => {
135
151
const stats = await compile ( compiler ) ;
136
152
137
153
for ( const [ name , info ] of stats . compilation . assetsInfo ) {
138
- if ( name . endsWith ( 'png' ) ) {
139
- expect ( info . immutable ) . toBe ( false ) ;
154
+ if ( name . startsWith ( 'asset.png' ) ) {
155
+ // eslint-disable-next-line no-undefined
156
+ expect ( info . immutable ) . toBe ( undefined ) ;
140
157
}
141
158
}
142
159
} ) ;
0 commit comments