Skip to content

Commit 0d4cc14

Browse files
committed
Add tests
1 parent 6a64628 commit 0d4cc14

File tree

2 files changed

+78
-16
lines changed

2 files changed

+78
-16
lines changed

tests/tests/src/jsx_preserve_test.mjs

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Generated by ReScript, PLEASE EDIT WITH CARE
22

3+
import * as React from "react";
34
import * as JsxRuntime from "react/jsx-runtime";
45

56
function Jsx_preserve_test$Icon(props) {
@@ -208,11 +209,9 @@ let _props_with_hyphen = <label
208209
data-testid={"test"}
209210
/>;
210211

211-
let React = {};
212-
213-
let _fragment = <Fragment>
212+
let _fragment = <>
214213
{"Hello, world!"}
215-
</Fragment>;
214+
</>;
216215

217216
let _youtube_iframe = <iframe
218217
allow={"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"}
@@ -224,6 +223,47 @@ let _youtube_iframe = <iframe
224223
referrerPolicy={"strict-origin-when-cross-origin"}
225224
/>;
226225

226+
function make(_props) {
227+
return null;
228+
}
229+
230+
let X = {
231+
make: make
232+
};
233+
234+
<X.make />;
235+
236+
function Jsx_preserve_test$Y(props) {
237+
return null;
238+
}
239+
240+
let make$1 = React.memo(Jsx_preserve_test$Y);
241+
242+
let Y = {
243+
x: 42,
244+
make: make$1
245+
};
246+
247+
<Y.make />;
248+
249+
let context = React.createContext(0);
250+
251+
let make$2 = context.Provider;
252+
253+
let ContextProvider = {
254+
make: make$2
255+
};
256+
257+
function Jsx_preserve_test(props) {
258+
return <ContextProvider.make
259+
value={42}
260+
>
261+
{props.children}
262+
</ContextProvider.make>;
263+
}
264+
265+
let make$3 = Jsx_preserve_test;
266+
227267
export {
228268
Icon,
229269
_single_element_child,
@@ -250,8 +290,12 @@ export {
250290
ComponentWithOptionalProps,
251291
_optional_props,
252292
_props_with_hyphen,
253-
React,
254293
_fragment,
255294
_youtube_iframe,
295+
X,
296+
Y,
297+
context,
298+
ContextProvider,
299+
make$3 as make,
256300
}
257301
/* _single_element_child Not a pure module */

tests/tests/src/jsx_preserve_test.res

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,6 @@ let _optional_props = <ComponentWithOptionalProps i=1 s="test" element={<div />}
129129

130130
let _props_with_hyphen = <label ariaLabel={"close sidebar"} dataTestId="test" />
131131

132-
module React = {
133-
type component<'props> = Jsx.component<'props>
134-
type element = Jsx.element
135-
136-
external jsx: (component<'props>, 'props) => element = "jsx"
137-
138-
type fragmentProps = {children?: element}
139-
140-
external jsxFragment: component<fragmentProps> = "Fragment"
141-
}
142-
143132
let _fragment = <> {Jsx.string("Hello, world!")} </>
144133

145134
let _youtube_iframe =
@@ -153,3 +142,32 @@ let _youtube_iframe =
153142
allowFullScreen={true}
154143
>
155144
</iframe>
145+
146+
module X = {
147+
type props = {}
148+
let make = (_props: props) => React.null
149+
}
150+
151+
let _ = <X />
152+
153+
module Y = {
154+
let x = 42
155+
156+
@react.component
157+
let make = () => React.null
158+
159+
let make = React.memo(make)
160+
}
161+
162+
let _ = <Y />
163+
164+
let context = React.createContext(0)
165+
166+
module ContextProvider = {
167+
let make = React.Context.provider(context)
168+
}
169+
170+
@react.component
171+
let make = (~children) => {
172+
<ContextProvider value=42> {children} </ContextProvider>
173+
}

0 commit comments

Comments
 (0)