|
3 | 3 | // Should consolidate them here. |
4 | 4 |
|
5 | 5 | import { context } from './testlib'; |
6 | | -import { ctxTsNode, testsDirRequire } from './helpers'; |
| 6 | +import { |
| 7 | + ctxTsNode, |
| 8 | + testsDirRequire, |
| 9 | + tsSupportsImportAssertions, |
| 10 | + tsSupportsReact17JsxFactories, |
| 11 | +} from './helpers'; |
7 | 12 | import { createSwcOptions } from '../transpilers/swc'; |
8 | 13 | import * as expect from 'expect'; |
9 | 14 | import { outdent } from 'outdent'; |
@@ -76,8 +81,11 @@ test.suite('swc', (test) => { |
76 | 81 | ); |
77 | 82 |
|
78 | 83 | test(macro, 'react', undefined, undefined); |
79 | | - test(macro, 'react-jsx', 'automatic', undefined); |
80 | | - test(macro, 'react-jsxdev', 'automatic', true); |
| 84 | + test.suite('react 17 jsx factories', (test) => { |
| 85 | + test.runIf(tsSupportsReact17JsxFactories); |
| 86 | + test(macro, 'react-jsx', 'automatic', undefined); |
| 87 | + test(macro, 'react-jsxdev', 'automatic', true); |
| 88 | + }); |
81 | 89 | }); |
82 | 90 | }); |
83 | 91 |
|
@@ -113,31 +121,35 @@ test.suite('swc', (test) => { |
113 | 121 | input, |
114 | 122 | `const div = /*#__PURE__*/ React.createElement("div", null);` |
115 | 123 | ); |
116 | | - test( |
117 | | - compileMacro, |
118 | | - { jsx: 'react-jsx' }, |
119 | | - input, |
120 | | - outdent` |
121 | | - import { jsx as _jsx } from "react/jsx-runtime"; |
122 | | - const div = /*#__PURE__*/ _jsx("div", {}); |
123 | | - ` |
124 | | - ); |
125 | | - test( |
126 | | - compileMacro, |
127 | | - { jsx: 'react-jsxdev' }, |
128 | | - input, |
129 | | - outdent` |
130 | | - import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime"; |
131 | | - const div = /*#__PURE__*/ _jsxDEV("div", {}, void 0, false, { |
132 | | - fileName: "input.tsx", |
133 | | - lineNumber: 1, |
134 | | - columnNumber: 13 |
135 | | - }, this); |
136 | | - ` |
137 | | - ); |
| 124 | + test.suite('react 17 jsx factories', (test) => { |
| 125 | + test.runIf(tsSupportsReact17JsxFactories); |
| 126 | + test( |
| 127 | + compileMacro, |
| 128 | + { jsx: 'react-jsx' }, |
| 129 | + input, |
| 130 | + outdent` |
| 131 | + import { jsx as _jsx } from "react/jsx-runtime"; |
| 132 | + const div = /*#__PURE__*/ _jsx("div", {}); |
| 133 | + ` |
| 134 | + ); |
| 135 | + test( |
| 136 | + compileMacro, |
| 137 | + { jsx: 'react-jsxdev' }, |
| 138 | + input, |
| 139 | + outdent` |
| 140 | + import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime"; |
| 141 | + const div = /*#__PURE__*/ _jsxDEV("div", {}, void 0, false, { |
| 142 | + fileName: "input.tsx", |
| 143 | + lineNumber: 1, |
| 144 | + columnNumber: 13 |
| 145 | + }, this); |
| 146 | + ` |
| 147 | + ); |
| 148 | + }); |
138 | 149 | }); |
139 | 150 |
|
140 | 151 | test.suite('preserves import assertions for json imports', (test) => { |
| 152 | + test.runIf(tsSupportsImportAssertions); |
141 | 153 | test( |
142 | 154 | 'basic json import', |
143 | 155 | compileMacro, |
|
0 commit comments