File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -64,6 +64,112 @@ describe("eval target", () => {
6464 stderr : "" ,
6565 } ) ;
6666 } ) ;
67+
68+ it ( "can evaluate jsx" , async ( ) => {
69+ const run = spawn ( binaryPath , [
70+ flag ,
71+ `<div><a key="hi" href="#" /><></></div>` ,
72+ "--lang" ,
73+ "jsx" ,
74+ ] ) ;
75+
76+ const Element = Symbol ( "JSX.Element" ) ;
77+ const Fragment = Symbol ( "JSX.Fragment" ) ;
78+
79+ await run . completion ;
80+ expect ( run . result ) . toEqual ( {
81+ code : 0 ,
82+ error : false ,
83+ stdout :
84+ inspect ( {
85+ $$typeof : Element ,
86+ type : "div" ,
87+ props : {
88+ children : [
89+ {
90+ $$typeof : Element ,
91+ type : "a" ,
92+ props : {
93+ key : "hi" ,
94+ href : "#" ,
95+ } ,
96+ key : "hi" ,
97+ } ,
98+ {
99+ $$typeof : Element ,
100+ type : Fragment ,
101+ props : null ,
102+ key : null ,
103+ } ,
104+ ] ,
105+ } ,
106+ key : null ,
107+ } ) + "\n" ,
108+ stderr : "" ,
109+ } ) ;
110+ } ) ;
111+
112+ [ "ts" , "typescript" ] . forEach ( ( lang ) => {
113+ it ( `can evaluate typescript (via --lang ${ lang } )` , async ( ) => {
114+ const run = spawn ( binaryPath , [
115+ flag ,
116+ `(function something<T>(blah: number): T { return 5 as any; }).name` ,
117+ "--lang" ,
118+ lang ,
119+ ] ) ;
120+ await run . completion ;
121+ expect ( run . result ) . toEqual ( {
122+ code : 0 ,
123+ error : false ,
124+ stdout : "something\n" ,
125+ stderr : "" ,
126+ } ) ;
127+ } ) ;
128+ } ) ;
129+
130+ it ( "can evaluate tsx" , async ( ) => {
131+ const run = spawn ( binaryPath , [
132+ flag ,
133+ `(function something(blah: number) { return <div><a key="hi" href="#" /><></></div> })()` ,
134+ "--lang" ,
135+ "tsx" ,
136+ ] ) ;
137+
138+ const Element = Symbol ( "JSX.Element" ) ;
139+ const Fragment = Symbol ( "JSX.Fragment" ) ;
140+
141+ await run . completion ;
142+ expect ( run . result ) . toEqual ( {
143+ code : 0 ,
144+ error : false ,
145+ stdout :
146+ inspect ( {
147+ $$typeof : Element ,
148+ type : "div" ,
149+ props : {
150+ children : [
151+ {
152+ $$typeof : Element ,
153+ type : "a" ,
154+ props : {
155+ key : "hi" ,
156+ href : "#" ,
157+ } ,
158+ key : "hi" ,
159+ } ,
160+ {
161+ $$typeof : Element ,
162+ type : Fragment ,
163+ props : null ,
164+ key : null ,
165+ } ,
166+ ] ,
167+ } ,
168+ key : null ,
169+ } ) + "\n" ,
170+ stderr : "" ,
171+ } ) ;
172+ } ) ;
67173 } ) ;
68174 } ) ;
69175} ) ;
You can’t perform that action at this time.
0 commit comments