1
1
import * as bundle from './bundle' ;
2
- import * as rollup from './rollup' ;
3
2
import * as webpack from './webpack' ;
4
3
import * as Constants from './util/constants' ;
5
4
import { ChangedFile } from './util/interfaces' ;
6
5
7
6
describe ( 'bundle task' , ( ) => {
8
7
9
8
describe ( 'bundle' , ( ) => {
10
- it ( 'should return the value rollup task returns' , ( ) => {
11
- // arrange
12
- spyOn ( rollup , rollup . rollup . name ) . and . returnValue ( Promise . resolve ( ) ) ;
13
- const context = { bundler : Constants . BUNDLER_ROLLUP } ;
14
-
15
- // act
16
- return bundle . bundle ( context ) . then ( ( ) => {
17
- // assert
18
- expect ( rollup . rollup ) . toHaveBeenCalled ( ) ;
19
- } ) ;
20
- } ) ;
21
-
22
- it ( 'should throw when rollup throws' , ( ) => {
23
- const errorText = 'simulating an error' ;
24
- // arrange
25
- spyOn ( rollup , rollup . rollup . name ) . and . returnValue ( Promise . reject ( new Error ( errorText ) ) ) ;
26
- const context = { bundler : Constants . BUNDLER_ROLLUP } ;
27
-
28
- // act
29
- return bundle . bundle ( context ) . then ( ( ) => {
30
- throw new Error ( 'Should never happen' ) ;
31
- } ) . catch ( err => {
32
- // assert
33
- expect ( rollup . rollup ) . toHaveBeenCalled ( ) ;
34
- expect ( err . message ) . toBe ( errorText ) ;
35
- } ) ;
36
- } ) ;
37
9
38
10
it ( 'should return the value webpack task returns' , ( ) => {
39
11
// arrange
@@ -47,7 +19,7 @@ describe('bundle task', () => {
47
19
} ) ;
48
20
} ) ;
49
21
50
- it ( 'should throw when rollup throws' , ( ) => {
22
+ it ( 'should throw when webpack throws' , ( ) => {
51
23
const errorText = 'simulating an error' ;
52
24
// arrange
53
25
spyOn ( webpack , webpack . webpack . name ) . and . returnValue ( Promise . reject ( new Error ( errorText ) ) ) ;
@@ -65,35 +37,6 @@ describe('bundle task', () => {
65
37
} ) ;
66
38
67
39
describe ( 'bundleUpdate' , ( ) => {
68
- it ( 'should return the value rollup returns' , ( ) => {
69
- // arrange
70
- spyOn ( rollup , rollup . rollupUpdate . name ) . and . returnValue ( Promise . resolve ( ) ) ;
71
- const context = { bundler : Constants . BUNDLER_ROLLUP } ;
72
- const changedFiles : ChangedFile [ ] = [ ] ;
73
-
74
- // act
75
- return bundle . bundleUpdate ( changedFiles , context ) . then ( ( ) => {
76
- // assert
77
- expect ( rollup . rollupUpdate ) . toHaveBeenCalledWith ( changedFiles , context ) ;
78
- } ) ;
79
- } ) ;
80
-
81
- it ( 'should throw when rollup throws' , ( ) => {
82
- const errorText = 'simulating an error' ;
83
- // arrange
84
- spyOn ( rollup , rollup . rollupUpdate . name ) . and . returnValue ( Promise . reject ( new Error ( errorText ) ) ) ;
85
- const context = { bundler : Constants . BUNDLER_ROLLUP } ;
86
- const changedFiles : ChangedFile [ ] = [ ] ;
87
-
88
- // act
89
- return bundle . bundleUpdate ( changedFiles , context ) . then ( ( ) => {
90
- throw new Error ( 'Should never happen' ) ;
91
- } ) . catch ( err => {
92
- // assert
93
- expect ( rollup . rollupUpdate ) . toHaveBeenCalled ( ) ;
94
- expect ( err . message ) . toBe ( errorText ) ;
95
- } ) ;
96
- } ) ;
97
40
98
41
it ( 'should return the value webpack returns' , ( ) => {
99
42
// arrange
@@ -132,20 +75,6 @@ describe('bundle task', () => {
132
75
} ) ;
133
76
134
77
describe ( 'buildJsSourceMaps' , ( ) => {
135
- it ( 'should get the value from the rollup config' , ( ) => {
136
- // arrange
137
- const config = {
138
- sourceMap : true
139
- } ;
140
- spyOn ( rollup , rollup . getRollupConfig . name ) . and . returnValue ( config ) ;
141
- const context = { bundler : Constants . BUNDLER_ROLLUP } ;
142
- // act
143
- const result = bundle . buildJsSourceMaps ( context ) ;
144
-
145
- // assert
146
- expect ( rollup . getRollupConfig ) . toHaveBeenCalledWith ( context , null ) ;
147
- expect ( result ) . toEqual ( config . sourceMap ) ;
148
- } ) ;
149
78
150
79
it ( 'should get false when devtool is null for webpack' , ( ) => {
151
80
// arrange
@@ -175,21 +104,6 @@ describe('bundle task', () => {
175
104
} ) ;
176
105
177
106
describe ( 'getJsOutputDest' , ( ) => {
178
- it ( 'should get the value from rollup' , ( ) => {
179
- // arrange
180
- const config = { } ;
181
- const returnValue = 'someString' ;
182
- spyOn ( rollup , rollup . getRollupConfig . name ) . and . returnValue ( config ) ;
183
- spyOn ( rollup , rollup . getOutputDest . name ) . and . returnValue ( returnValue ) ;
184
- const context = { bundler : Constants . BUNDLER_ROLLUP } ;
185
- // act
186
- const result = bundle . getJsOutputDest ( context ) ;
187
-
188
- // assert
189
- expect ( rollup . getRollupConfig ) . toHaveBeenCalledWith ( context , null ) ;
190
- expect ( rollup . getOutputDest ) . toHaveBeenCalledWith ( context , config ) ;
191
- expect ( result ) . toEqual ( returnValue ) ;
192
- } ) ;
193
107
194
108
it ( 'should get the value from webpack' , ( ) => {
195
109
// arrange
0 commit comments