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

Commit 9180a12

Browse files
committedFeb 22, 2017
Test inline fallbacks
1 parent 9b66560 commit 9180a12

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed
 
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const w1 = require('./w1.js');
2+
const w2 = require('./w2.js');

‎test/fixtures/inline-fallbacks/w1.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// w1 inlined with fallback

‎test/fixtures/inline-fallbacks/w2.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// w2 inlined with fallback

‎test/index.js

+31
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,35 @@ describe('worker-loader', () => {
116116
assert.notEqual(readFile(bundleFile).indexOf('// w2 inlined via options'), -1);
117117
})
118118
);
119+
120+
it('should add fallback chunks with inline option', () =>
121+
makeBundle('inline-fallbacks', {
122+
module: {
123+
rules: [
124+
{
125+
test: /(w1|w2)\.js$/,
126+
loader: '../index.js',
127+
options: {
128+
inline: true,
129+
},
130+
},
131+
],
132+
},
133+
}).then((stats) => {
134+
const files = stats.toJson('minimal').children
135+
.map(item => item.chunks)
136+
.reduce((acc, item) => acc.concat(item), [])
137+
.map(item => item.files)
138+
.map(item => `expected/inline-fallbacks/${item}`);
139+
assert.equal(files.length, 2);
140+
const w1 = readFile(files[0]);
141+
const w2 = readFile(files[1]);
142+
if (w1.indexOf('// w1 via worker options') !== -1) {
143+
assert.notEqual(w2.indexOf('// w2 via worker options'), -1);
144+
}
145+
if (w1.indexOf('// w2 via worker options') !== -1) {
146+
assert.notEqual(w2.indexOf('// w1 via worker options'), -1);
147+
}
148+
})
149+
);
119150
});

0 commit comments

Comments
 (0)
This repository has been archived.