File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -229,3 +229,13 @@ module RecordTypeInputTesting =
229229 ]
230230 )
231231 ]
232+
233+ module NullnessTesting =
234+
235+ [<ReactComponent>]
236+ let NullishPropComponent (maybeText: string | null) =
237+ Html.div [
238+ match maybeText with
239+ | null -> Html.h1 [ prop.testId "no-text"; prop.text "No text provided." ]
240+ | text -> Html.h1 [ prop.testId "has-text"; prop.text text ]
241+ ]
Original file line number Diff line number Diff line change @@ -264,3 +264,24 @@ describe "Props Aliasing Tests #687" <| fun _ ->
264264
265265 let c = RTL.screen.getByTestId " props-aliasing"
266266 expect( c) .toBeInTheDocument()
267+
268+ describe " Nullness Tests" <| fun _ ->
269+
270+ test " Component with nullable prop handles null correctly" <| fun _ ->
271+ RTL.render(
272+ NullnessTesting.NullishPropComponent( null )
273+ ) |> ignore
274+
275+ let noText = RTL.screen.getByTestId " no-text"
276+ expect( noText) .toBeInTheDocument()
277+ expect( noText) .toHaveTextContent( " No text provided." )
278+
279+ test " Component with nullable prop handles non-null correctly" <| fun _ ->
280+
281+ RTL.render(
282+ NullnessTesting.NullishPropComponent( " Hello, Nullable!" )
283+ ) |> ignore
284+
285+ let hasText = RTL.screen.getByTestId " has-text"
286+ expect( hasText) .toBeInTheDocument()
287+ expect( hasText) .toHaveTextContent( " Hello, Nullable!" )
You can’t perform that action at this time.
0 commit comments