/
compiler.test.ts
38 lines (31 loc) · 1.01 KB
/
compiler.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import * as babel from '@babel/core';
import * as path from 'node:path';
import preset from '..';
function getCaller(props: Record<string, string | boolean>): babel.TransformCaller {
return props as unknown as babel.TransformCaller;
}
const options = {
caller: getCaller({ name: 'metro', engine: 'hermes', platform: 'ios', isDev: true }),
babelrc: false,
presets: [preset],
sourceMaps: false,
compact: false,
comments: true,
retainLines: true,
};
it(`allows destructuring in the catch block`, () => {
// Ensuring the transform doesn't throw.
const { code } = babel.transformFileSync(
path.resolve(__dirname, 'samples/destructure-catch.tsx'),
options
)!;
expect(code).toMatchSnapshot();
});
it(`supports functions with discarded return values in try/catch blocks that run in memos`, () => {
// Ensuring the transform doesn't throw.
const { code } = babel.transformFileSync(
path.resolve(__dirname, 'samples/try-catch-hook.tsx'),
options
)!;
expect(code).toMatchSnapshot();
});