pragmatic-fp-ts
Version:
Opinionated functional programming library with easy use in mind
20 lines (16 loc) • 550 B
text/typescript
import { endsWith } from "../main.ts";
describe("endsWith()", () => {
it("works for strings", () => {
expect(endsWith("ar")("foobar")).toBe(true);
expect(endsWith("foor", "foobar")).toBe(false);
});
it("works for arrays", () => {
expect(endsWith(1)([3, 2, 1])).toBe(true);
expect(endsWith(1, [1, 2, 3])).toBe(false);
});
it("works for longer tails", () => {
expect(endsWith([2, 1])([3, 2, 1])).toBe(true);
expect(endsWith([2, 1], [1, 2, 3])).toBe(false);
expect(endsWith([], [1, 2, 3])).toBe(true);
});
});