UNPKG

rescript-test

Version:

> A lightweight test framework for ReScript

113 lines (94 loc) 3.26 kB
// Generated by ReScript, PLEASE EDIT WITH CARE import * as Test from "../src/Test.mjs"; import * as Caml_obj from "rescript/lib/es6/caml_obj.js"; import * as Belt_Option from "rescript/lib/es6/belt_Option.js"; import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js"; function equal(message, a, b) { Test.assertion(message, "equal", (function (a, b) { return a === b; }), a, b); } function deepEqual(message, a, b) { Test.assertion(message, "deepEqual", Caml_obj.equal, a, b); } function equalAsString(message, a, b) { Test.assertion(message, "equal", (function (a, b) { return String(a) === b; }), a, b); } Test.testAsync("Async", undefined, (function (cb) { setTimeout((function () { equal(undefined, 1, 1); equalAsString(undefined, 1, "1"); cb(undefined, undefined); }), 100); })); Test.testAsync("Async", 10, (function (_cb) { })); Test.test("Equals", (function () { equal(undefined, 1, 1); })); Test.test("Should fail", (function () { Test.fail(undefined, undefined); })); Test.test("Should throw", (function () { Test.throws(undefined, undefined, (function () { throw new Error("Helloooo"); })); Test.throws("Should not be a JS error", (function (error) { return Belt_Option.isNone(Caml_js_exceptions.as_js_exn(error)); }), (function () { throw new Error("Helloooo"); })); })); Test.test("Should not throw", (function () { Test.doesNotThrow(undefined, (function () { })); })); Test.test("DeepEquals", (function () { equal(undefined, "user", "user"); equal(undefined, "user", "a"); equal(undefined, 1, undefined); deepEqual(undefined, { username: "user", id: "a" }, { username: "user", id: "a" }); Test.todo("Check that user is ok"); })); Test.testAsync("Async with planned under", undefined, (function (cb) { setTimeout((function () { equal(undefined, 1, 1); equalAsString(undefined, 1, "1"); cb(0, undefined); }), 100); })); Test.testAsync("Async with planned exact", undefined, (function (cb) { setTimeout((function () { equal(undefined, 1, 1); equalAsString(undefined, 1, "1"); cb(2, undefined); }), 100); })); Test.testAsync("Async with planned over", undefined, (function (cb) { setTimeout((function () { equal(undefined, 1, 1); equalAsString(undefined, 1, "1"); cb(3, undefined); }), 100); })); Test.testAsync("Async with planned and fails", undefined, (function (cb) { setTimeout((function () { equal(undefined, 1, 2); equalAsString(undefined, 1, "1"); cb(2, undefined); }), 100); })); export { equal , deepEqual , equalAsString , } /* Not a pure module */