@@ -64,7 +64,7 @@ describe('process', () => {
|
64 | 64 | typescript = { options: {} } as any
|
65 | 65 | })
|
66 | 66 |
|
67 |
| -it('should process input without babel', () => { |
| 67 | +it('should process ts input without babel', () => { |
68 | 68 | expect(process()).toBe(`ts:${INPUT}`)
|
69 | 69 | expect(config.shouldStringifyContent.mock.calls).toMatchInlineSnapshot(`
|
70 | 70 | Array [
|
@@ -83,7 +83,28 @@ Array [
|
83 | 83 | `)
|
84 | 84 | })
|
85 | 85 |
|
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', () => { |
87 | 108 | babel = { process: jest.fn(s => `babel:${s}`) }
|
88 | 109 | expect(process()).toBe(`babel:ts:${INPUT}`)
|
89 | 110 | expect(config.shouldStringifyContent.mock.calls).toMatchInlineSnapshot(`
|
@@ -115,6 +136,40 @@ Array [
|
115 | 136 | `)
|
116 | 137 | })
|
117 | 138 |
|
| 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 | + |
118 | 173 | it('should return stringified version of file', () => {
|
119 | 174 | config.shouldStringifyContent.mockImplementation(() => true)
|
120 | 175 | expect(process()).toMatchInlineSnapshot(`"module.exports=\\"export default \\\\\\"foo\\\\\\"\\""`)
|
|
0 commit comments