1
- /* eslint-env mocha */
2
-
3
1
const api = require ( '../lib/runtime/api' ) ;
4
2
5
3
describe ( 'css-base' , ( ) => {
6
- before ( ( ) => {
4
+ beforeAll ( ( ) => {
7
5
global . btoa = function btoa ( str ) {
8
6
let buffer = null ;
9
7
10
8
if ( str instanceof Buffer ) {
11
9
buffer = str ;
12
10
} else {
13
- buffer = new Buffer ( str . toString ( ) , 'binary' ) ;
11
+ buffer = Buffer . from ( str . toString ( ) , 'binary' ) ;
14
12
}
15
13
16
14
return buffer . toString ( 'base64' ) ;
17
15
} ;
18
16
} ) ;
19
17
20
- after ( ( ) => {
18
+ afterAll ( ( ) => {
21
19
global . btoa = null ;
22
20
} ) ;
23
21
24
22
it ( 'should toString a single module' , ( ) => {
25
23
const m = api ( ) ;
26
24
m . push ( [ 1 , 'body { a: 1; }' , '' ] ) ;
27
- m . toString ( ) . should . be . eql ( 'body { a: 1; }' ) ;
25
+ expect ( m . toString ( ) ) . toBe ( 'body { a: 1; }' ) ;
28
26
} ) ;
29
27
it ( 'should toString multiple modules' , ( ) => {
30
28
const m = api ( ) ;
31
29
m . push ( [ 2 , 'body { b: 2; }' , '' ] ) ;
32
30
m . push ( [ 1 , 'body { a: 1; }' , '' ] ) ;
33
- m . toString ( ) . should . be . eql ( 'body { b: 2; }body { a: 1; }' ) ;
31
+ expect ( m . toString ( ) ) . toBe ( 'body { b: 2; }body { a: 1; }' ) ;
34
32
} ) ;
35
33
it ( 'should toString with media query' , ( ) => {
36
34
const m = api ( ) ;
37
35
m . push ( [ 1 , 'body { a: 1; }' , 'screen' ] ) ;
38
- m . toString ( ) . should . be . eql ( '@media screen{body { a: 1; }}' ) ;
36
+ expect ( m . toString ( ) ) . toBe ( '@media screen{body { a: 1; }}' ) ;
39
37
} ) ;
40
38
it ( 'should import modules' , ( ) => {
41
39
const m = api ( ) ;
@@ -47,7 +45,7 @@ describe('css-base', () => {
47
45
m . i ( [ m2 ] , '' ) ;
48
46
m . i ( [ m2 , m4 ] , 'print' ) ;
49
47
m . push ( m1 ) ;
50
- m . toString ( ) . should . be . eql (
48
+ expect ( m . toString ( ) ) . toBe (
51
49
'body { b: 2; }' +
52
50
'body { c: 3; }' +
53
51
'@media print{body { d: 4; }}' +
@@ -64,7 +62,7 @@ describe('css-base', () => {
64
62
m . i ( [ m2 ] , '' ) ;
65
63
m . i ( [ m2 , m4 ] , 'print' ) ;
66
64
m . push ( m1 ) ;
67
- m . toString ( ) . should . be . eql (
65
+ expect ( m . toString ( ) ) . toBe (
68
66
'body { b: 2; }' +
69
67
'body { c: 3; }' +
70
68
'@media print{body { d: 4; }}' +
@@ -84,7 +82,7 @@ describe('css-base', () => {
84
82
sourceRoot : 'webpack://' ,
85
83
} ,
86
84
] ) ;
87
- m . toString ( ) . should . be . eql (
85
+ expect ( m . toString ( ) ) . toBe (
88
86
'body { a: 1; }\n/*# sourceURL=webpack://./path/to/test.scss */\n/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoidGVzdC5zY3NzIiwic291cmNlcyI6WyIuL3BhdGgvdG8vdGVzdC5zY3NzIl0sIm1hcHBpbmdzIjoiQUFBQTsiLCJzb3VyY2VSb290Ijoid2VicGFjazovLyJ9 */'
89
87
) ;
90
88
} ) ;
@@ -102,6 +100,6 @@ describe('css-base', () => {
102
100
sourceRoot : 'webpack://' ,
103
101
} ,
104
102
] ) ;
105
- m . toString ( ) . should . be . eql ( 'body { a: 1; }' ) ;
103
+ expect ( m . toString ( ) ) . toBe ( 'body { a: 1; }' ) ;
106
104
} ) ;
107
105
} ) ;
0 commit comments