UNPKG

@applicaster/zapp-react-native-utils

Version:

Applicaster Zapp React Native utilities package

31 lines (24 loc) 913 B
import { startsWith } from "../startsWith"; describe("startsWith", () => { it("returns false when str is null", () => { expect(startsWith("a", null)).toBe(false); }); it("returns false when str is undefined", () => { expect(startsWith("a", undefined)).toBe(false); }); it("returns true when string starts with target", () => { expect(startsWith("he", "hello")).toBe(true); expect(startsWith("", "hello")).toBe(true); // empty target always matches }); it("returns false when string does not start with target", () => { expect(startsWith("yo", "hello")).toBe(false); }); it("works with single character target", () => { expect(startsWith("h", "hello")).toBe(true); expect(startsWith("x", "hello")).toBe(false); }); it("is case-sensitive", () => { expect(startsWith("He", "hello")).toBe(false); expect(startsWith("he", "hello")).toBe(true); }); });