import "mocha"; import { expect } from "chai"; import { TypeOf } from "@valuer/types"; import { is, numbers, negpos } from "../helpers"; describe('Thunk factory "is.a"', () => { it("recognizes values by kind-agnostic type-like parameter", () => { for (const value of [ "text", new String("text") ]) for (const type of [ ( "string"), String ]) expect(is.a(type)(value)).to.be.true; for (const value of negpos(numbers)) for (const type of [ ( "number"), Number ]) expect(is.a(type)(value)).to.be.true; const Thing = class {}; const Thingy = class {}; const thing = new Thing(); const thunk = is.a(Thing); expect(thunk(thing)).to.be.true; expect(thunk({})).to.be.false; expect(is.a(Thingy)(thing)).to.be.false; }); });