UNPKG

react-use-locale-number-input

Version:

A React hook for formatting number inputs based on the user's locale.

38 lines 1.77 kB
import { __awaiter, __generator } from "tslib"; import { renderHook } from "@testing-library/react"; import { useLocaleNumberInput } from "../useLocaleNumberInput"; describe("useLocaleNumberInput", function () { it("should return the hook params", function () { return __awaiter(void 0, void 0, void 0, function () { var result; return __generator(this, function (_a) { result = renderHook(function () { return useLocaleNumberInput(1000.59, "de-DE", function () { }); }).result; expect(typeof result.current.handleBlur).toBe("function"); expect(typeof result.current.handleBlur).toBe("function"); expect(typeof result.current.value).toBe("string"); return [2 /*return*/]; }); }); }); it("should return the hook params for de-DE", function () { return __awaiter(void 0, void 0, void 0, function () { var result; return __generator(this, function (_a) { result = renderHook(function () { return useLocaleNumberInput(1000.59, "de-DE", function () { }); }).result; expect(result.current.value).toBe("1.000,59"); return [2 /*return*/]; }); }); }); it("should return the hook params for en-US", function () { return __awaiter(void 0, void 0, void 0, function () { var result; return __generator(this, function (_a) { result = renderHook(function () { return useLocaleNumberInput(1000.59, "en-US", function () { }); }).result; expect(result.current.value).toBe("1,000.59"); return [2 /*return*/]; }); }); }); }); //# sourceMappingURL=useLocaleNumberInput.test.js.map