Skip to content

Commit 6f1f558

Browse files
Tests for no script or style bundles
1 parent fed3fa9 commit 6f1f558

1 file changed

Lines changed: 78 additions & 8 deletions

File tree

src/bundle-orchastrator.test.ts

Lines changed: 78 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ interface IBundleBuilderFlags {
6060
* Don't include any bundle specs.
6161
*/
6262
noBundles?: boolean;
63+
64+
/**
65+
* Don't include any style bundles.
66+
*/
67+
noStyleBundles?: boolean;
68+
69+
/**
70+
* Don't include any script bundles.
71+
*/
72+
noScriptBundles?: boolean;
6373
}
6474

6575
/**
@@ -78,14 +88,18 @@ function buildBundler(t: ExecutionContext, flags: IBundleBuilderFlags = {}) {
7888
? undefined
7989
: {
8090
bund1: {
81-
scripts: [
82-
"./123/bar.js",
83-
"./abc/foo.js",
84-
],
85-
styles: [
86-
"./123/foo.css",
87-
"./abc/foo.css",
88-
]
91+
scripts: flags.noScriptBundles
92+
? undefined
93+
: [
94+
"./123/bar.js",
95+
"./abc/foo.js",
96+
],
97+
styles: flags.noStyleBundles
98+
? undefined
99+
: [
100+
"./123/foo.css",
101+
"./abc/foo.css",
102+
]
89103
}
90104
}
91105
},
@@ -184,6 +198,62 @@ test("No bundles to build", async t => {
184198
);
185199
});
186200

201+
test("No style bundles", async t => {
202+
const result = await getStream.array(
203+
intoStream.object([
204+
new Vinyl({ path: resolvePath("./123/bar.js") }),
205+
new Vinyl({ path: resolvePath("./123/foo.css") }),
206+
new Vinyl({ path: resolvePath("./abc/foo.css") }),
207+
new Vinyl({ path: resolvePath("./abc/foo.js") }),
208+
])
209+
.pipe(buildBundler(t, { noStyleBundles: true }))
210+
) as Vinyl[];
211+
212+
t.deepEqual(
213+
sortOn(result, 'history'),
214+
sortOn(
215+
[
216+
// Original inputs
217+
new Vinyl({ path: resolvePath("./123/bar.js") }),
218+
new Vinyl({ path: resolvePath("./123/foo.css") }),
219+
new Vinyl({ path: resolvePath("./abc/foo.css") }),
220+
new Vinyl({ path: resolvePath("./abc/foo.js") }),
221+
// Bundles
222+
new Vinyl({ path: resolvePath("./bund1.js") }),
223+
],
224+
'history'
225+
)
226+
);
227+
});
228+
229+
test("No script bundles", async t => {
230+
const result = await getStream.array(
231+
intoStream.object([
232+
new Vinyl({ path: resolvePath("./123/bar.js") }),
233+
new Vinyl({ path: resolvePath("./123/foo.css") }),
234+
new Vinyl({ path: resolvePath("./abc/foo.css") }),
235+
new Vinyl({ path: resolvePath("./abc/foo.js") }),
236+
])
237+
.pipe(buildBundler(t, { noScriptBundles: true }))
238+
) as Vinyl[];
239+
240+
t.deepEqual(
241+
sortOn(result, 'history'),
242+
sortOn(
243+
[
244+
// Original inputs
245+
new Vinyl({ path: resolvePath("./123/bar.js") }),
246+
new Vinyl({ path: resolvePath("./123/foo.css") }),
247+
new Vinyl({ path: resolvePath("./abc/foo.css") }),
248+
new Vinyl({ path: resolvePath("./abc/foo.js") }),
249+
// Bundles
250+
new Vinyl({ path: resolvePath("./bund1.css") }),
251+
],
252+
'history'
253+
)
254+
);
255+
});
256+
187257
test("Non-vinyl chunk pushed out when feed in", async t => {
188258
try {
189259
const result = await getStream.array(

0 commit comments

Comments
 (0)