Spaces:
Configuration error
Configuration error
Download frontend/__tests__/utils/amount-is-valid.test.ts from flyingdarkdev/README: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/__tests__/utils/amount-is-valid.test.ts
- Command line
-
hf download hf://spaces/flyingdarkdev/README/frontend/__tests__/utils/amount-is-valid.test.ts
-
curl -L -o amount-is-valid.test.ts https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/__tests__/utils/amount-is-valid.test.ts
1.23 kB
| import { describe, expect, test } from "vitest"; | |
| import { amountIsValid } from "#/utils/amount-is-valid"; | |
| describe("amountIsValid", () => { | |
| describe("fails", () => { | |
| test("when the amount is negative", () => { | |
| expect(amountIsValid("-5")).toBe(false); | |
| expect(amountIsValid("-25")).toBe(false); | |
| }); | |
| test("when the amount is zero", () => { | |
| expect(amountIsValid("0")).toBe(false); | |
| }); | |
| test("when an empty string is passed", () => { | |
| expect(amountIsValid("")).toBe(false); | |
| expect(amountIsValid(" ")).toBe(false); | |
| }); | |
| test("when a non-numeric value is passed", () => { | |
| expect(amountIsValid("abc")).toBe(false); | |
| expect(amountIsValid("1abc")).toBe(false); | |
| expect(amountIsValid("abc1")).toBe(false); | |
| }); | |
| test("when an amount less than the minimum is passed", () => { | |
| // test assumes the minimum is 10 | |
| expect(amountIsValid("9")).toBe(false); | |
| expect(amountIsValid("9.99")).toBe(false); | |
| }); | |
| test("when an amount more than the maximum is passed", () => { | |
| // test assumes the minimum is 25000 | |
| expect(amountIsValid("25001")).toBe(false); | |
| expect(amountIsValid("25000.01")).toBe(false); | |
| }); | |
| }); | |
| }); | |