-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproc.mli
454 lines (387 loc) · 13.6 KB
/
proc.mli
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
open! Core
open! Import
module Linter = Virtual_dom_test_helpers.Node_helpers.Linter
module Result_spec : sig
include module type of struct
include Bonsai_test.Result_spec
end
(** Construct a result spec for printing vdoms in tests.
[filter_printed_attributes] controls which attributes on a Node will get
printed analyzing the string name of the attribute. Style properties
correspond to their property name prefixed with "style.". For example, to
filter out the "display" CSS property, you should return false for
"style.display"; to filter out all CSS styles, return false when the
string begins with "style.". A Node's key corresponds to the string
"@key".
In the snippet:
```html
<div key1="data1" key2="data2"></div>
```
"key"'s are the left hand side of the equal and "data"'s are the right hand
side of the equal sign. This is different from the naming convention mentioned in
mdn's https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes name's and
value's.
┌───────┬────────┐
│ mdn │ bonsai │
├───────┼────────┤
│ name │ key │
│ value │ data │
└───────┴────────┘
*)
val vdom
: ?filter_printed_attributes:(key:string -> data:string -> bool)
-> ?censor_paths:bool
-> ?censor_hash:bool
-> ?path_censoring_message:string
-> ?hash_censoring_message:string
-> ?lint_min_severity:Linter.Severity.t
(** [lint_min_severity] defaults to [Fatal]. *)
-> ?lint_expected_failures:Linter.Rule.t list
-> ('a -> Vdom.Node.t)
-> ('a, Nothing.t) t
end
module Handle : sig
include module type of struct
include Bonsai_test.Handle
end
val create
: ('a, 'b) Result_spec.t
-> ?rpc_implementations:
Async_rpc_kernel.Rpc.Connection.t Async_rpc_kernel.Rpc.Implementation.t list
-> ?connectors:(Rpc_effect.Where_to_connect.t -> Rpc_effect.Connector.t)
(** By default [connectors] always returns
[Bonsai_web.Rpc_effect.Connector.test_fallback], which uses any provided
[rpc_implementations] to handle any dispatched RPCs. *)
-> ?start_time:Time_ns.t
-> ?optimize:bool
-> 'a Computation.t
-> ('a, 'b) t
(** Runs [recompute_view] and [Async_kernel_scheduler.yield_until_no_jobs_remain]
in a loop until nothing remains to be done. This is a good sledgehammer
function to use if you want to wait until all the effects of a user-action
have completed.
By default, this function prints "------ between bonsai frame ------" in between
each iteration to demonstrate when side-effects occur, and how long it took for a
stable state to be reached. This line is just extra documentation; it is not
necessarily a sign that something is wrong (unless, of course, the behavior of the
thing you're trying to test shouldn't result in an extra frame). These lines can be
removed by passing [~silence_between_frames:true] in case your tests take a
non-deterministic number of iterations to stabilize.
[max_iterations] controls how many loop iterations are allowed before the
function aborts with an exception, in case the default of 100 is too low.
However, you should rarely, if ever need this parameter.
*)
val flush_async_and_bonsai
: ?max_iterations:int
-> ?silence_between_frames:bool
-> ('a, 'b) t
-> unit Async_kernel.Deferred.t
(** [min_severity] defaults to [High]. *)
val lint_vdom
: ?min_severity:Linter.Severity.t
-> ?expected_failures:Linter.Rule.t list
-> ('a, 'b) t
-> get_vdom:('a -> Vdom.Node.t)
-> unit
val click_on
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ?shift_key_down:bool
-> ?alt_key_down:bool
-> ?ctrl_key_down:bool
-> ('a, 'b) t
-> get_vdom:('a -> Vdom.Node.t)
-> selector:string
-> unit
val submit_form
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ('a, 'b) t
-> get_vdom:('a -> Vdom.Node.t)
-> selector:string
-> unit
val set_checkbox
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ?shift_key_down:bool
-> ?alt_key_down:bool
-> ?ctrl_key_down:bool
-> ('a, 'b) t
-> get_vdom:('a -> Vdom.Node.t)
-> selector:string
-> checked:bool
-> unit
val input_text
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ('a, 'b) t
-> get_vdom:('a -> Vdom.Node.t)
-> selector:string
-> text:string
-> unit
val input_files
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ('a, 'b) t
-> get_vdom:('a -> Vdom.Node.t)
-> selector:string
-> files:Js_of_ocaml.File.file Js_of_ocaml.Js.t list
-> unit
val keydown
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ?shift_key_down:bool
-> ?alt_key_down:bool
-> ?ctrl_key_down:bool
-> ('a, 'b) t
-> get_vdom:('a -> Vdom.Node.t)
-> selector:string
-> key:Js_of_ocaml.Dom_html.Keyboard_code.t
-> unit
val change
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ('a, 'b) t
-> get_vdom:('a -> Vdom.Node.t)
-> selector:string
-> value:string
-> unit
val focus
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ('a, 'b) t
-> get_vdom:('a -> Vdom.Node.t)
-> selector:string
-> unit
val blur
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ?related_target:string
-> ('a, 'b) t
-> get_vdom:('a -> Vdom.Node.t)
-> selector:string
-> unit
val mousemove
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ('a, 'b) t
-> get_vdom:('a -> Vdom.Node.t)
-> selector:string
-> unit
val mouseenter
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ('a, 'b) t
-> get_vdom:('a -> Vdom.Node.t)
-> selector:string
-> unit
val wheel
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ('a, 'b) t
-> get_vdom:('a -> Vdom.Node.t)
-> selector:string
-> delta_y:float
-> unit
val trigger_hook
: ('a, 'b) t
-> get_vdom:('a -> Vdom.Node.t)
-> selector:string
-> name:string
-> ('c -> unit Vdom.Effect.t) Type_equal.Id.t
-> 'c
-> unit
val trigger_hook_via
: ('a, 'b) t
-> get_vdom:('a -> Vdom.Node.t)
-> selector:string
-> name:string
-> 't Type_equal.Id.t
-> f:('t -> 'c -> unit Vdom.Effect.t)
-> 'c
-> unit
val get_hook_value
: ('a, 'b) t
-> get_vdom:('a -> Vdom.Node.t)
-> selector:string
-> name:string
-> 'c Type_equal.Id.t
-> 'c
end
module Experimental : sig
module Result_spec : sig
module type S = sig
include Bonsai_test.Result_spec.S
val to_vdom : t -> Vdom.Node.t
end
type ('result, 'incoming) t =
(module S with type t = 'result and type incoming = 'incoming)
(** [filter_printed_attributes] controls which attributes on a Node will get
printed analyzing the string name of the attribute. Style properties
correspond to their property name prefixed with "style.". For example, to
filter out the "display" CSS property, you should return false for
"style.display"; to filter out all CSS styles, return false when the
string begins with "style.". A Node's key corresponds to the string
"@key".
In the snippet:
```html
<div key1="data1" key2="data2"></div>
```
"key"'s are the left hand side of the equal and "data"'s are the right hand
side of the equal sign. This is different from the naming convention mentioned in
mdn's https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes name's and
value's.
┌───────┬────────┐
│ mdn │ bonsai │
├───────┼────────┤
│ name │ key │
│ value │ data │
└───────┴────────┘
*)
val vdom
: ?filter_printed_attributes:(key:string -> data:string -> bool)
-> ?censor_paths:bool
-> ?censor_hash:bool
-> ?path_censoring_message:string
-> ?hash_censoring_message:string
-> ?to_string:(Vdom.Node.t -> string)
-> unit
-> (Vdom.Node.t, Nothing.t) t
module No_incoming = Bonsai_test.Result_spec.No_incoming
module type Sexpable = Bonsai_test.Result_spec.Sexpable
module type Stringable = Bonsai_test.Result_spec.Stringable
val sexp : (module Sexpable with type t = 'a) -> ('a, Nothing.t) t
val string : (module Stringable with type t = 'a) -> ('a, Nothing.t) t
end
module Handle : sig
type ('result, 'incoming) t
val create
: ('a, 'b) Result_spec.t
-> ?rpc_implementations:
Async_rpc_kernel.Rpc.Connection.t Async_rpc_kernel.Rpc.Implementation.t list
-> ?connectors:(Rpc_effect.Where_to_connect.t -> Rpc_effect.Connector.t)
(** By default [connectors] always returns
[Bonsai_web.Rpc_effect.Connector.test_fallback], which uses any provided
[rpc_implementations] to handle any dispatched RPCs. *)
-> ?start_time:Time_ns.t
-> ?optimize:bool
-> 'a Computation.t
-> ('a, 'b) t
(** [show] prints out the result of the component as specified by the [Result_spec] that
was passed into [Handle.create]. *)
val show : _ t -> unit
val store_view : _ t -> unit
val show_diff
: ?location_style:Patdiff_kernel.Format.Location_style.t
-> ?diff_context:int
-> _ t
-> unit
val time_source : _ t -> Bonsai.Time_source.t
val advance_clock_by : _ t -> Time_ns.Span.t -> unit
val advance_clock : to_:Time_ns.t -> _ t -> unit
val do_actions : (_, 'incoming) t -> 'incoming list -> unit
(** [recompute_view] is like [show], but it doesn't print anything. Calling
[recompute_view] between invocations of [show_diff] does not affect the
diff the gets shown. *)
val recompute_view : _ t -> unit
(** returns the most recently computed result *)
val result : ('r, _) t -> 'r
(** This function calls [recompute_view] until either
[max_computes] is reached (defaults to 100), or there are no more
after-display lifecycle events for processing.
This can be useful when using e.g. [Bonsai.Edge.on_change], which might
otherwise delay their effects until the next frame. *)
val recompute_view_until_stable : ?max_computes:int -> _ t -> unit
val flush_async_and_bonsai
: ?max_iterations:int
-> ?silence_between_frames:bool
-> _ t
-> unit Async_kernel.Deferred.t
val click_on
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ?shift_key_down:bool
-> ?alt_key_down:bool
-> ?ctrl_key_down:bool
-> ('a, 'b) t
-> selector:string
-> unit
val submit_form
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ('a, 'b) t
-> selector:string
-> unit
val set_checkbox
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ?shift_key_down:bool
-> ?alt_key_down:bool
-> ?ctrl_key_down:bool
-> ('a, 'b) t
-> selector:string
-> checked:bool
-> unit
val input_text
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ('a, 'b) t
-> selector:string
-> text:string
-> unit
val input_files
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ('a, 'b) t
-> selector:string
-> files:Js_of_ocaml.File.file Js_of_ocaml.Js.t list
-> unit
val keydown
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ?shift_key_down:bool
-> ?alt_key_down:bool
-> ?ctrl_key_down:bool
-> ('a, 'b) t
-> selector:string
-> key:Js_of_ocaml.Dom_html.Keyboard_code.t
-> unit
val change
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ('a, 'b) t
-> selector:string
-> value:string
-> unit
val focus
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ('a, 'b) t
-> selector:string
-> unit
val blur
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ?related_target:string
-> ('a, 'b) t
-> selector:string
-> unit
val mousemove
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ('a, 'b) t
-> selector:string
-> unit
val mouseenter
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ('a, 'b) t
-> selector:string
-> unit
val wheel
: ?extra_event_fields:(string * Js_of_ocaml.Js.Unsafe.any) list
-> ('a, 'b) t
-> selector:string
-> delta_y:float
-> unit
val trigger_hook
: ('a, 'b) t
-> selector:string
-> name:string
-> ('c -> unit Vdom.Effect.t) Type_equal.Id.t
-> 'c
-> unit
val trigger_hook_via
: ('a, 'b) t
-> selector:string
-> name:string
-> 't Type_equal.Id.t
-> f:('t -> 'c -> unit Vdom.Effect.t)
-> 'c
-> unit
val get_hook_value
: ('a, 'b) t
-> selector:string
-> name:string
-> 'c Type_equal.Id.t
-> 'c
end
end
module Expect_test_config : Expect_test_config_types.S with module IO = Monad.Ident