UNPKG

hypertune

Version:

[Hypertune](https://www.hypertune.com/) is the most flexible platform for feature flags, A/B testing, analytics and app configuration. Built with full end-to-end type-safety, Git-style version control and local, synchronous, in-memory flag evaluation. Opt

27 lines (22 loc) 610 B
import { expect, test } from "vitest"; import nullThrows from "./nullThrows"; const EXAMPLE_MESSAGE = "Expected value, but got null or undefined"; test("throws on null", () => { expect(() => nullThrows(null, EXAMPLE_MESSAGE)).toThrow(EXAMPLE_MESSAGE); }); test("throws on undefined", () => { expect(() => nullThrows(undefined, EXAMPLE_MESSAGE)).toThrow(EXAMPLE_MESSAGE); }); test.each([ [[]], [["content"]], [false], [true], [0], [1], [NaN], [new Date()], [new Date("Not a date string")], ])("returns %s", (value) => { expect(nullThrows(value, EXAMPLE_MESSAGE)).toEqual(value); });