Skip to content

Commit

Permalink
bs-promise -> Js.Promise
Browse files Browse the repository at this point in the history
  • Loading branch information
glennsl committed Apr 19, 2017
1 parent fbec3c1 commit ad231a8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 31 deletions.
4 changes: 2 additions & 2 deletions __tests__/globals_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let _ =
testAsync "testAsync - expect fail" (fun done_ -> done_ (expect (1 + 2) |> toBe 4));
*)

testPromise "testPromise" (fun _ -> Promise.resolve (expect (1 + 2) |> toBe 3));
testPromise "testPromise" (fun _ -> Js.Promise.resolve (expect (1 + 2) |> toBe 3));
(*
testPromise "testPromise - reject" (fun _ -> Promise.reject ());
*)
Expand Down Expand Up @@ -86,7 +86,7 @@ let _ =
done_ (expect (1 + 2) |> toBe 3));

Skip.testPromise "Skip.testPromise" (fun _ ->
Promise.resolve (expect (1 + 2) |> toBe 3));
Js.Promise.resolve (expect (1 + 2) |> toBe 3));

Skip.describe "Skip.describe" (fun _ ->
test "some aspect" (fun _ -> expect (1 + 2) |> toBe 3)
Expand Down
3 changes: 1 addition & 2 deletions bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
}, {
"dir": "__tests__",
"type": "dev"
}],
"bs-dependencies": ["bs-promise"]
}]
}
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
},
"homepage": "https://github.com/BuckleTypes/bs-jest#readme",
"devDependencies": {
"bs-platform": "^1.6.0"
"bs-platform": "^1.7.1"
},
"dependencies": {
"jest": "^19.0.2",
"bs-promise": "^0.3.1"
"jest": "^19.0.2"
}
}
20 changes: 8 additions & 12 deletions src/jest.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@

module Promise = Bs_promise
type ('a, 'e) promise = ('a, 'e) Promise.t

type 'a simpleAssertion =
| Ok : 'a simpleAssertion
| Fail : string -> 'a simpleAssertion
Expand Down Expand Up @@ -144,10 +140,10 @@ module Runner (A : Asserter) = struct
done_ ());
Js.undefined)

external testPromise : string -> (unit -> ('a, 'e) promise) -> unit = "test" [@@bs.val]
external testPromise : string -> (unit -> 'a Js.Promise.t) -> unit = "test" [@@bs.val]
let testPromise name callback =
testPromise name (fun () ->
callback () |> Promise.then_ A.assert_)
callback () |> Js.Promise.then_ (fun a -> a |> A.assert_ |> Js.Promise.resolve))

external describe : string -> (unit -> unit) -> unit = "" [@@bs.val]

Expand All @@ -171,18 +167,18 @@ module Runner (A : Asserter) = struct
done_ ());
Js.undefined)

external testPromise : string -> (unit -> ('a, 'e) promise) -> unit = "test.only" [@@bs.val]
external testPromise : string -> (unit -> 'a Js.Promise.t) -> unit = "test.only" [@@bs.val]
let testPromise name callback =
testPromise name (fun () ->
callback () |> Promise.then_ A.assert_)
callback () |> Js.Promise.then_ (fun a -> a |> A.assert_ |> Js.Promise.resolve))

external describe : string -> (unit -> unit) -> unit = "describe.only" [@@bs.val]
end

module Skip = struct
external test : string -> (unit -> 'a A.t) -> unit = "test.skip" [@@bs.val]
external testAsync : string -> (('a A.t -> unit) -> unit) -> unit = "test.skip" [@@bs.val]
external testPromise : string -> (unit -> ('a A.t, 'e) promise) -> unit = "test.skip" [@@bs.val]
external testPromise : string -> (unit -> 'a A.t Js.Promise.t) -> unit = "test.skip" [@@bs.val]
external describe : string -> (unit -> unit) -> unit = "describe.skip" [@@bs.val]
end
end
Expand All @@ -206,11 +202,11 @@ let testAsyncOnly name callback =
external testAsyncSkip : string -> (('a assertion -> unit) -> unit) -> unit = "test.skip" [@@bs.val]
[@@ocaml.deprecated "Use `Skip.testAsync` instead"]

external testPromiseOnly : string -> (unit -> ('a, 'e) promise) -> unit = "test.only" [@@bs.val]
external testPromiseOnly : string -> (unit -> 'a Js.Promise.t) -> unit = "test.only" [@@bs.val]
let testPromiseOnly name callback =
testPromiseOnly name (fun () -> callback () |> Promise.then_ LLExpect.assert_)
testPromiseOnly name (fun () -> callback () |> Js.Promise.then_ (fun assertion -> Js.Promise.resolve LLExpect.assert_))
[@@ocaml.deprecated "Use `Only.testPromise` instead"]
external testPromiseSkip : string -> (unit -> ('a assertion, 'e) promise) -> unit = "test.skip" [@@bs.val]
external testPromiseSkip : string -> (unit -> 'a assertion Js.Promise.t) -> unit = "test.skip" [@@bs.val]
[@@ocaml.deprecated "Use `Skip.testPromise` instead"]

external describeOnly : string -> (unit -> unit) -> unit = "describe.only" [@@bs.val]
Expand Down
20 changes: 8 additions & 12 deletions src/jest.mli
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@

module Promise = Bs_promise
type ('a, 'e) promise = ('a, 'e) Promise.t

type 'a assertion

module type Asserter = sig
Expand All @@ -12,7 +8,7 @@ end
module Runner (A : Asserter) : sig
val test : string -> (unit -> 'a A.t) -> unit
val testAsync : string -> (('a A.t -> unit) -> unit) -> unit
val testPromise : string -> (unit -> ('a A.t, 'e) promise) -> unit
val testPromise : string -> (unit -> 'a A.t Js.Promise.t) -> unit

external describe : string -> (unit -> unit) -> unit = "" [@@bs.val]

Expand All @@ -24,21 +20,21 @@ module Runner (A : Asserter) : sig
module Only : sig
val test : string -> (unit -> 'a A.t) -> unit
val testAsync : string -> (('a A.t -> unit) -> unit) -> unit
val testPromise : string -> (unit -> ('a A.t, 'e) promise) -> unit
val testPromise : string -> (unit -> 'a A.t Js.Promise.t) -> unit
external describe : string -> (unit -> unit) -> unit = "describe.only" [@@bs.val]
end

module Skip : sig
external test : string -> (unit -> 'a A.t) -> unit = "test.skip" [@@bs.val]
external testAsync : string -> (('a A.t -> unit) -> unit) -> unit = "test.skip" [@@bs.val]
external testPromise : string -> (unit -> ('a A.t, 'e) promise) -> unit = "test.skip" [@@bs.val]
external testPromise : string -> (unit -> 'a A.t Js.Promise.t) -> unit = "test.skip" [@@bs.val]
external describe : string -> (unit -> unit) -> unit = "describe.skip" [@@bs.val]
end
end

val test : string -> (unit -> 'a assertion) -> unit
val testAsync : string -> (('a assertion -> unit) -> unit) -> unit
val testPromise : string -> (unit -> ('a assertion, 'e) promise) -> unit
val testPromise : string -> (unit -> 'a assertion Js.Promise.t) -> unit

external describe : string -> (unit -> unit) -> unit = "" [@@bs.val]

Expand All @@ -50,14 +46,14 @@ external afterEach : (unit -> unit) -> unit = "" [@@bs.val]
module Only : sig
val test : string -> (unit -> 'a assertion) -> unit
val testAsync : string -> (('a assertion -> unit) -> unit) -> unit
val testPromise : string -> (unit -> ('a assertion, 'e) promise) -> unit
val testPromise : string -> (unit -> 'a assertion Js.Promise.t) -> unit
external describe : string -> (unit -> unit) -> unit = "describe.only" [@@bs.val]
end

module Skip : sig
external test : string -> (unit -> 'a assertion) -> unit = "test.skip" [@@bs.val]
external testAsync : string -> (('a assertion -> unit) -> unit) -> unit = "test.skip" [@@bs.val]
external testPromise : string -> (unit -> ('a assertion, 'e) promise) -> unit = "test.skip" [@@bs.val]
external testPromise : string -> (unit -> 'a assertion Js.Promise.t) -> unit = "test.skip" [@@bs.val]
external describe : string -> (unit -> unit) -> unit = "describe.skip" [@@bs.val]
end

Expand All @@ -72,9 +68,9 @@ val testAsyncOnly : string -> (('a assertion -> unit) -> unit) -> unit
[@@ocaml.deprecated "Use `Only.testAsync` instead"]
external testAsyncSkip : string -> (('a assertion -> unit) -> unit) -> unit = "test.skip" [@@bs.val]
[@@ocaml.deprecated "Use `Skip.testAsync` instead"]
val testPromiseOnly : string -> (unit -> ('a assertion, 'e) promise) -> unit
val testPromiseOnly : string -> (unit -> 'a assertion Js.Promise.t) -> unit
[@@ocaml.deprecated "Use `Only.testPromise` instead"]
external testPromiseSkip : string -> (unit -> ('a assertion, 'e) promise) -> unit = "test.skip" [@@bs.val]
external testPromiseSkip : string -> (unit -> 'a assertion Js.Promise.t) -> unit = "test.skip" [@@bs.val]
[@@ocaml.deprecated "Use `Skip.testPromise` instead"]
external describeOnly : string -> (unit -> unit) -> unit = "describe.only" [@@bs.val]
[@@ocaml.deprecated "Use `Only.describe` instead"]
Expand Down

0 comments on commit ad231a8

Please sign in to comment.