File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
packages/react-live/src/utils Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { generateElement } from "../../transpile" ;
2
+ import { shallow } from "../renderer" ;
3
+
4
+ describe ( "transpile" , ( ) => {
5
+ it ( "should support optional chain" , ( ) => {
6
+ const code = `function Demo() {
7
+ return <h3 style={{
8
+ background: 'darkslateblue',
9
+ color: 'white',
10
+ padding: 8,
11
+ borderRadius: 4
12
+ }}>
13
+ {'1'?.toString()}
14
+ </h3>
15
+ }` ;
16
+ const Component = generateElement ( { code } ) ;
17
+ const wrapper = shallow ( < Component /> ) ;
18
+
19
+ expect ( wrapper . html ( ) ) . toMatchInlineSnapshot (
20
+ `"<h3 style=\\"background:darkslateblue;color:white;padding:8px;border-radius:4px\\">1</h3>"`
21
+ ) ;
22
+ } ) ;
23
+ } ) ;
Original file line number Diff line number Diff line change @@ -35,10 +35,10 @@ export const generateElement = (
35
35
const transformed = compose < string > (
36
36
addJsxConst ,
37
37
transform ( { transforms : [ "imports" ] } ) ,
38
- wrapReturn ,
39
38
spliceJsxConst ,
40
39
trimCode ,
41
40
transform ( { transforms : firstPassTransforms } ) ,
41
+ wrapReturn ,
42
42
trimCode
43
43
) ( code ) ;
44
44
You can’t perform that action at this time.
0 commit comments