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 = (
3535 const transformed = compose < string > (
3636 addJsxConst ,
3737 transform ( { transforms : [ "imports" ] } ) ,
38- wrapReturn ,
3938 spliceJsxConst ,
4039 trimCode ,
4140 transform ( { transforms : firstPassTransforms } ) ,
41+ wrapReturn ,
4242 trimCode
4343 ) ( code ) ;
4444
You can’t perform that action at this time.
0 commit comments