Skip to content

Instantly share code, notes, and snippets.

@tiensonqin
Created November 14, 2017 06:24
Show Gist options
  • Save tiensonqin/f3370df6b894946bf3e750d4696920b0 to your computer and use it in GitHub Desktop.
Save tiensonqin/f3370df6b894946bf3e750d4696920b0 to your computer and use it in GitHub Desktop.
open Jest
open Atom
let _ = test "Atom create" @@
fun () -> begin
let a = atom 0 in
ignore Expect.(expect @@ deref a |> toBe 0);
addWatch a 0 (fun _key _atom oldV newV ->
Js.log "oldV";
Js.log oldV;
Js.log "newV";
Js.log newV;
);
Js.log a.watches;
ignore @@ reset a 1;
ignore @@ Expect.(expect @@ deref a |> toBe 1);
ignore @@ (swap a @@ fun x -> x + 1);
Expect.(expect @@ deref a |> toBe 2);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment