@@ -8,47 +8,44 @@ describe( 'rollup-plugin-typescript', function () {
8
8
this . timeout ( 5000 ) ;
9
9
10
10
it ( 'runs code through typescript' , function ( ) {
11
- var start = Date . now ( ) ;
12
-
13
11
return rollup . rollup ( {
14
12
entry : 'sample/basic/main.ts' ,
15
13
plugins : [
16
14
typescript ( )
17
15
]
18
16
} ) . then ( function ( bundle ) {
19
- console . log ( 'bundled in %s ms' , Date . now ( ) - start ) ;
20
-
21
- start = Date . now ( ) ;
22
17
const generated = bundle . generate ( ) ;
23
- console . log ( 'generated in %s ms' , Date . now ( ) - start ) ;
24
-
25
18
const code = generated . code ;
26
19
27
20
assert . ok ( code . indexOf ( 'number' ) === - 1 , code ) ;
28
21
assert . ok ( code . indexOf ( 'const' ) === - 1 , code ) ;
29
22
} ) ;
30
23
} ) ;
31
24
32
- it ( 'transpiles ES6 features to ES5' , function ( ) {
33
- var start = Date . now ( ) ;
34
-
25
+ it ( 'transpiles ES6 features to ES5 with source maps' , function ( ) {
35
26
return rollup . rollup ( {
36
27
entry : 'sample/import-class/main.ts' ,
37
28
plugins : [
38
29
typescript ( )
39
30
]
40
31
} ) . then ( function ( bundle ) {
41
- console . log ( 'bundled in %s ms' , Date . now ( ) - start ) ;
42
-
43
- start = Date . now ( ) ;
44
32
const generated = bundle . generate ( ) ;
45
- console . log ( 'generated in %s ms' , Date . now ( ) - start ) ;
46
-
47
33
const code = generated . code ;
48
34
49
35
assert . ok ( code . indexOf ( 'class' ) === - 1 , code ) ;
50
36
assert . ok ( code . indexOf ( '...' ) === - 1 , code ) ;
51
37
assert . ok ( code . indexOf ( '=>' ) === - 1 , code ) ;
52
38
} ) ;
53
39
} ) ;
40
+
41
+ it ( 'reports diagnostics and throws if errors occur during transpilation' , function ( ) {
42
+ return rollup . rollup ( {
43
+ entry : 'sample/syntax-error/missing-type.ts' ,
44
+ plugins : [
45
+ typescript ( )
46
+ ]
47
+ } ) . catch ( function ( error ) {
48
+ assert . ok ( error . message . indexOf ( 'There were TypeScript errors' ) === 0 , 'Should reject erroneous code.' ) ;
49
+ } ) ;
50
+ } ) ;
54
51
} ) ;
0 commit comments