-
Notifications
You must be signed in to change notification settings - Fork 68
/
index.test.tsx
41 lines (37 loc) · 1.17 KB
/
index.test.tsx
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
39
40
41
import * as ts from 'typescript';
import rootTransformer from '../index';
import pkg from '../../../package.json';
describe('root transformer', () => {
it('should not blow up when transforming with const', () => {
const transformer = rootTransformer({});
expect(() => {
ts.transpileModule(
`
/** @jsx jsx */
import { jsx } from '${pkg.name}';
const MyComponent = () => <div css={{ fontSize: '20px' }}>hello world</div>
`,
{
transformers: { before: transformer },
compilerOptions: { module: ts.ModuleKind.ESNext, jsx: ts.JsxEmit.React },
}
);
}).not.toThrow();
});
it('should not blow up when transforming with var', () => {
const transformer = rootTransformer({});
expect(() => {
ts.transpileModule(
`
/** @jsx jsx */
import { jsx } from '${pkg.name}';
var MyComponent = () => <div css={{ fontSize: '20px' }}>hello world</div>
`,
{
transformers: { before: transformer },
compilerOptions: { module: ts.ModuleKind.ESNext, jsx: ts.JsxEmit.React },
}
);
}).not.toThrow();
});
});