import "mocha"; import { expect } from "chai"; import { is, funcs } from "../helpers"; describe('Thunk factory "is.ofType"', () => { it("recognizes values by their `typeof` result", () => { const values = [ 42, "text", true, Symbol.iterator, {}, () => {}, undefined ]; for (const value of values) expect(is.ofType(typeof value)(value)).to.be.true; expect(is.ofType("string")(42)).to.be.false; expect(is.ofType("number")("")).to.be.false; }); it("accepts any number of type-like arguments", () => { const thunk = is.ofType("string", "number"); const valid = [ 42, "text" ]; const invalid = funcs; for (const value of valid) expect(thunk(value)).to.be.true; for (const value of invalid) expect(thunk(value)).to.be.false; }); });