1
+ const build = require ( '../../src/index' ) ;
2
+ const fs = require ( 'fs' ) ;
3
+ const JSDOM = require ( 'jsdom' ) . JSDOM ;
4
+ const encoding = 'utf8' ;
5
+
6
+ describe ( 'stripBom default' , ( ) => {
7
+ const outputFile = './test/stripBom/dist/default/index.html' ;
8
+
9
+ beforeAll ( async ( ) => {
10
+ await build ( {
11
+ input : './test/stripBom/src' ,
12
+ output : './test/stripBom/dist/default'
13
+ } ) ;
14
+ } ) ;
15
+
16
+ describe ( 'index.html' , ( ) => {
17
+ let html ;
18
+
19
+ beforeAll ( async ( ) => {
20
+ html = await fs . promises . readFile ( outputFile , encoding ) ;
21
+ } ) ;
22
+
23
+ it ( 'has no BOM' , ( ) => {
24
+ expect ( / \uFEFF / . test ( html ) ) . toEqual ( false ) ;
25
+ } ) ;
26
+ } ) ;
27
+ } ) ;
28
+
29
+ describe ( 'stripBom false' , ( ) => {
30
+ const outputFile = './test/stripBom/dist/false/index.html' ;
31
+
32
+ beforeAll ( async ( ) => {
33
+ await build ( {
34
+ input : './test/stripBom/src' ,
35
+ output : './test/stripBom/dist/false' ,
36
+ stripBom : false
37
+ } ) ;
38
+ } ) ;
39
+
40
+ describe ( 'index.html' , ( ) => {
41
+ let html ;
42
+
43
+ beforeAll ( async ( ) => {
44
+ html = await fs . promises . readFile ( outputFile , encoding ) ;
45
+ } ) ;
46
+
47
+ it ( 'has a BOM in the content' , ( ) => {
48
+ expect ( / \uFEFF < p > / . test ( html ) ) . toEqual ( true ) ;
49
+ } ) ;
50
+ } ) ;
51
+ } ) ;
0 commit comments