@@ -6,24 +6,14 @@ const test = require('ava');
66const { rollup, watch } = require ( 'rollup' ) ;
77const ts = require ( 'typescript' ) ;
88
9- const { getCode, testBundle } = require ( '../../../util/test' ) ;
9+ const { evaluateBundle , getCode, onwarn } = require ( '../../../util/test' ) ;
1010
1111const typescript = require ( '..' ) ;
1212
1313test . beforeEach ( ( ) => process . chdir ( __dirname ) ) ;
1414
1515const outputOptions = { format : 'esm' } ;
1616
17- async function evaluateBundle ( bundle ) {
18- const { module } = await testBundle ( null , bundle ) ;
19- return module . exports ;
20- }
21-
22- function onwarn ( warning ) {
23- // eslint-disable-next-line no-console
24- console . warn ( warning . toString ( ) ) ;
25- }
26-
2717test . serial ( 'runs code through typescript' , async ( t ) => {
2818 const bundle = await rollup ( {
2919 input : 'fixtures/basic/main.ts' ,
@@ -263,7 +253,7 @@ test.serial('ignore type errors if noEmitOnError is false', async (t) => {
263253
264254 t . true ( code . includes ( `console.log('hello world')` ) ) ;
265255
266- t . is ( warnings . length , 1 ) ;
256+ t . is ( warnings . length , 2 ) ;
267257
268258 t . is ( warnings [ 0 ] . code , 'PLUGIN_WARNING' ) ;
269259 t . is ( warnings [ 0 ] . plugin , 'typescript' ) ;
@@ -333,38 +323,6 @@ test.serial('supports overriding the TypeScript version', async (t) => {
333323 t . is ( result , 1337 ) ;
334324} ) ;
335325
336- test . serial ( 'supports overriding tslib with a custom path' , async ( t ) => {
337- const bundle = await rollup ( {
338- input : 'fixtures/overriding-tslib/main.ts' ,
339- plugins : [
340- typescript ( {
341- tsconfig : 'fixtures/overriding-tslib/tsconfig.json' ,
342- tslib : 'fixtures/overriding-tslib/tslib.js'
343- } )
344- ] ,
345- onwarn
346- } ) ;
347- const code = await evaluateBundle ( bundle ) ;
348-
349- t . is ( code . myParent . baseMethod ( ) , 'base method' ) ;
350- } ) ;
351-
352- test . serial ( 'supports overriding tslib with a custom path in a promise' , async ( t ) => {
353- const bundle = await rollup ( {
354- input : 'fixtures/overriding-tslib/main.ts' ,
355- plugins : [
356- typescript ( {
357- tsconfig : 'fixtures/overriding-tslib/tsconfig.json' ,
358- tslib : Promise . resolve ( 'fixtures/overriding-tslib/tslib.js' )
359- } )
360- ] ,
361- onwarn
362- } ) ;
363- const code = await evaluateBundle ( bundle ) ;
364-
365- t . is ( code . myParent . baseMethod ( ) , 'base method' ) ;
366- } ) ;
367-
368326test . serial ( 'should not resolve .d.ts files' , async ( t ) => {
369327 const bundle = await rollup ( {
370328 input : 'fixtures/dts/main.ts' ,
@@ -521,19 +479,6 @@ test.serial('should throw on bad options', async (t) => {
521479 ] ) ;
522480} ) ;
523481
524- test . serial ( 'creates _tslib.js file when preserveModules is used' , async ( t ) => {
525- const bundle = await rollup ( {
526- input : 'fixtures/preserve-modules/main.ts' ,
527- plugins : [ typescript ( { tsconfig : 'fixtures/preserve-modules/tsconfig.json' } ) ] ,
528- preserveModules : true ,
529- onwarn
530- } ) ;
531-
532- const files = await getCode ( bundle , { format : 'es' } , true ) ;
533- t . true ( files [ 0 ] . fileName . includes ( 'main.js' ) , files [ 0 ] . fileName ) ;
534- t . true ( files [ 1 ] . fileName . includes ( 'tslib.es6.js' ) , files [ 1 ] . fileName ) ;
535- } ) ;
536-
537482test . serial ( 'should handle re-exporting types' , async ( t ) => {
538483 const bundle = await rollup ( {
539484 input : 'fixtures/reexport-type/main.ts' ,
0 commit comments