package jsoo-react

  1. Overview
  2. Docs

Source file reactDOMTestUtils.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
[@@@js.dummy "!! This code has been generated by gen_js_api !!"]
[@@@ocaml.warning "-7-32-39"]
type undefined = Ojs.t
let undefined = Ojs.variable "undefined"
let undefined_to_js x = x
let undefined_of_js x = x
type element = Js_of_ocaml.Dom_html.element
external element_of_js : Ojs.t -> Js_of_ocaml.Dom_html.element = "%identity"
external element_to_js : Js_of_ocaml.Dom_html.element -> Ojs.t = "%identity"
type 'a node_list = 'a Js_of_ocaml.Dom.nodeList
external node_list_of_ojs : Ojs.t -> 'value node_list = "%identity"
external node_list_to_js : 'value node_list -> Ojs.t = "%identity"
let node_list_of_js _f x = node_list_of_ojs x
let node_list_to_js _f x = node_list_to_js x
external unsafe_to_element : 'a Js_of_ocaml.Js.t -> element = "%identity"
let (act : (unit -> undefined) -> unit) =
  fun (x1 : unit -> undefined) ->
    ignore
      (Ojs.call (Ojs.get_prop_ascii Ojs.global "__LIB__reactDOMTestUtils")
         "act" [|(Ojs.fun_to_js 1 (fun _ -> undefined_to_js (x1 ())))|])
let act f = act (fun () -> f (); undefined)
module Simulate =
  struct
    let (click : element -> unit) =
      fun (x2 : element) ->
        ignore
          (Ojs.call
             (Ojs.get_prop_ascii
                (Ojs.get_prop_ascii Ojs.global "__LIB__reactDOMTestUtils")
                "Simulate") "click" [|(element_to_js x2)|])
  end
let (querySelectorAll : element -> string -> element node_list) =
  fun (x4 : element) ->
    fun (x3 : string) ->
      node_list_of_js element_of_js
        (Ojs.call (element_to_js x4) "querySelectorAll"
           [|(Ojs.string_to_js x3)|])
let (arrayFrom : element node_list -> element array) =
  fun (x6 : element node_list) ->
    Ojs.array_of_js element_of_js
      (Ojs.call (Ojs.get_prop_ascii Ojs.global "Array") "from"
         [|(node_list_to_js element_to_js x6)|])
let querySelectorAll element selector =
  arrayFrom (querySelectorAll element selector)
module DOM =
  struct
    let find f a =
      let rec find a f n = if f (a.(n)) then a.(n) else find a f (n + 1) in
      find a f 0
    let (textContent : element -> string) =
      fun (x9 : element) ->
        Ojs.string_of_js
          (Ojs.get_prop_ascii (element_to_js x9) "textContent")
    let (includes : string -> string -> bool) =
      fun (x11 : string) ->
        fun (x10 : string) ->
          Ojs.bool_of_js
            (Ojs.call (Ojs.string_to_js x11) "includes"
               [|(Ojs.string_to_js x10)|])
    let findBySelectorAndPartialTextContent element selector content =
      (querySelectorAll element selector) |>
        (find (fun node -> (textContent node) |> (includes content)))
  end
OCaml

Innovation. Community. Security.