UNPKG

@applicaster/zapp-react-native-utils

Version:

Applicaster Zapp React Native utilities package

31 lines (24 loc) 885 B
import { endsWith } from "../endsWith"; describe("endsWith", () => { it("returns false when str is null", () => { expect(endsWith("a", null)).toBe(false); }); it("returns false when str is undefined", () => { expect(endsWith("a", undefined)).toBe(false); }); it("returns true when string ends with target", () => { expect(endsWith("lo", "hello")).toBe(true); expect(endsWith("", "hello")).toBe(true); // empty target always matches }); it("returns false when string does not end with target", () => { expect(endsWith("yo", "hello")).toBe(false); }); it("works with single character target", () => { expect(endsWith("o", "hello")).toBe(true); expect(endsWith("x", "hello")).toBe(false); }); it("is case-sensitive", () => { expect(endsWith("Lo", "hello")).toBe(false); expect(endsWith("lo", "hello")).toBe(true); }); });