@@ -64,7 +64,7 @@ describe('process', () => {
6464 typescript = { options : { } } as any
6565 } )
6666
67- it ( 'should process input without babel' , ( ) => {
67+ it ( 'should process ts input without babel' , ( ) => {
6868 expect ( process ( ) ) . toBe ( `ts:${ INPUT } ` )
6969 expect ( config . shouldStringifyContent . mock . calls ) . toMatchInlineSnapshot ( `
7070Array [
@@ -83,7 +83,28 @@ Array [
8383` )
8484 } )
8585
86- it ( 'should process input with babel' , ( ) => {
86+ it ( 'should process js input without babel' , ( ) => {
87+ typescript . options . allowJs = true
88+ args [ 1 ] = '/foo/bar.js'
89+ expect ( process ( ) ) . toBe ( `ts:${ INPUT } ` )
90+ expect ( config . shouldStringifyContent . mock . calls ) . toMatchInlineSnapshot ( `
91+ Array [
92+ Array [
93+ "/foo/bar.js",
94+ ],
95+ ]
96+ ` )
97+ expect ( config . tsCompiler . compile . mock . calls ) . toMatchInlineSnapshot ( `
98+ Array [
99+ Array [
100+ "export default \\"foo\\"",
101+ "/foo/bar.js",
102+ ],
103+ ]
104+ ` )
105+ } )
106+
107+ it ( 'should process ts input with babel' , ( ) => {
87108 babel = { process : jest . fn ( s => `babel:${ s } ` ) }
88109 expect ( process ( ) ) . toBe ( `babel:ts:${ INPUT } ` )
89110 expect ( config . shouldStringifyContent . mock . calls ) . toMatchInlineSnapshot ( `
@@ -115,6 +136,40 @@ Array [
115136` )
116137 } )
117138
139+ it ( 'should process js input with babel' , ( ) => {
140+ typescript . options . allowJs = true
141+ babel = { process : jest . fn ( s => `babel:${ s } ` ) }
142+ args [ 1 ] = '/foo/bar.js'
143+ expect ( process ( ) ) . toBe ( `babel:ts:${ INPUT } ` )
144+ expect ( config . shouldStringifyContent . mock . calls ) . toMatchInlineSnapshot ( `
145+ Array [
146+ Array [
147+ "/foo/bar.js",
148+ ],
149+ ]
150+ ` )
151+ expect ( config . babelJestTransformer . process . mock . calls ) . toMatchInlineSnapshot ( `
152+ Array [
153+ Array [
154+ "ts:export default \\"foo\\"",
155+ "/foo/bar.js",
156+ Object {},
157+ Object {
158+ "instrument": false,
159+ },
160+ ],
161+ ]
162+ ` )
163+ expect ( config . tsCompiler . compile . mock . calls ) . toMatchInlineSnapshot ( `
164+ Array [
165+ Array [
166+ "export default \\"foo\\"",
167+ "/foo/bar.js",
168+ ],
169+ ]
170+ ` )
171+ } )
172+
118173 it ( 'should return stringified version of file' , ( ) => {
119174 config . shouldStringifyContent . mockImplementation ( ( ) => true )
120175 expect ( process ( ) ) . toMatchInlineSnapshot ( `"module.exports=\\"export default \\\\\\"foo\\\\\\"\\""` )
0 commit comments