@@ -5,24 +5,33 @@ import * as webpack from "webpack";
5
5
6
6
import { LoaderOptions } from "../../src/LoaderOptions" ;
7
7
import { WebpackAny } from "../../src/Plugin" ;
8
- import { config as basicConfig } from "../configs/basicConfig" ;
8
+ import { EntryTypes , config as basicConfig } from "../configs/basicConfig" ;
9
9
10
10
import { BLOCK_FIXTURES_DIRECTORY , DIST_DIRECTORY } from "./testPaths" ;
11
11
const CR = / \r / g;
12
12
13
13
// This test harness was adapted from the sass-loader test suite.
14
14
15
- export function execTest ( testId : string , options ?: LoaderOptions ) {
16
- const entryPath = path . join ( BLOCK_FIXTURES_DIRECTORY , testId + ".block.css" ) ;
17
- return runWebpackAsPromise ( basicConfig ( entryPath , options ) )
18
- . then ( ( ) => {
19
- const actualCss = readBundle ( "bundle.block.css.js" ) ;
20
- const expectedCss = readCss ( testId ) ;
15
+ export function execTest ( testId : string , options ?: LoaderOptions , entryFormat : "string" | "object" | "array" = "string" ) {
16
+ const entryPath : string = path . join ( BLOCK_FIXTURES_DIRECTORY , testId + ".block.css" ) ;
17
+ let entry : EntryTypes = entryPath ;
21
18
22
- // writing the actual css to output-dir for better debugging
23
- // fs.writeFileSync(path.join(__dirname, "output", `${ testId }.${ ext }.css`), actualCss, "utf8");
24
- assert . deepEqual ( actualCss , expectedCss ) ;
25
- } ) ;
19
+ if ( entryFormat === "array" ) {
20
+ entry = [ entryPath ] ;
21
+ }
22
+ else if ( entryFormat === "object" ) {
23
+ entry = { main : entryPath } ;
24
+ }
25
+
26
+ return runWebpackAsPromise ( basicConfig ( entry , options ) )
27
+ . then ( ( ) => {
28
+ const actualCss = readBundle ( "bundle.block.css.js" ) ;
29
+ const expectedCss = readCss ( testId ) ;
30
+
31
+ // writing the actual css to output-dir for better debugging
32
+ // fs.writeFileSync(path.join(__dirname, "output", `${ testId }.${ ext }.css`), actualCss, "utf8");
33
+ assert . deepEqual ( actualCss , expectedCss ) ;
34
+ } ) ;
26
35
}
27
36
28
37
export function readCss ( id : string ) : string {
0 commit comments