diff --git a/src/utilities/getFileName.test.js b/src/utilities/getFileName.test.js index 8b4a030..84cc16e 100644 --- a/src/utilities/getFileName.test.js +++ b/src/utilities/getFileName.test.js @@ -1,8 +1,8 @@ import { getFileName } from "./getFileName.js"; test("identify name without extension", () => { - expect(getFileName("name.extension")).toContain("name"); + expect(getFileName("name.extension")).toEqual("name"); expect(getFileName("/sub/path/name.extension")).toEqual("name"); - expect(getFileName("http://name.extension")).toContain("name"); - expect(getFileName("http://sub/path/name.extension")).toContain("name"); + expect(getFileName("http://name.extension")).toEqual("name"); + expect(getFileName("http://sub/path/name.extension")).toEqual("name"); }); diff --git a/src/utilities/toBoolean.js b/src/utilities/toBoolean.js index 3f1236e..acd55eb 100644 --- a/src/utilities/toBoolean.js +++ b/src/utilities/toBoolean.js @@ -1,3 +1,3 @@ export function toBoolean(value) { - return String(value) === "true"; + return String(value).toLowerCase() === "true"; } diff --git a/src/utilities/toBoolean.test.js b/src/utilities/toBoolean.test.js new file mode 100644 index 0000000..622d4a7 --- /dev/null +++ b/src/utilities/toBoolean.test.js @@ -0,0 +1,12 @@ +import { toBoolean } from "./toBoolean.js"; + +test("to boolean conversion", () => { + expect(toBoolean(true)).toBeTruthy(); + expect(toBoolean("true")).toBeTruthy(); + expect(toBoolean("TrUe")).toBeTruthy(); + expect(toBoolean(false)).toBeFalsy(); + expect(toBoolean("rue")).toBeFalsy(); + expect(toBoolean(1)).toBeFalsy(); + expect(toBoolean(null)).toBeFalsy(); + expect(toBoolean(undefined)).toBeFalsy(); +});