|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { parseWidth, isHexColor } from "../src/utils/validator"; |
| 3 | + |
| 4 | +describe("Width parser", () => { |
| 5 | + it("should return 495 because the number is not valid", () => { |
| 6 | + expect(parseWidth("hi")).toEqual(495); |
| 7 | + }); |
| 8 | + |
| 9 | + it("should return 495", () => { |
| 10 | + expect(parseWidth("495")).toEqual(495); |
| 11 | + }); |
| 12 | + |
| 13 | + it("should return 495", () => { |
| 14 | + expect(parseWidth()).toEqual(495); |
| 15 | + }); |
| 16 | + |
| 17 | + it("should return 123", () => { |
| 18 | + expect(parseWidth("123")).toEqual(123); |
| 19 | + }); |
| 20 | + |
| 21 | + it("should return 643", () => { |
| 22 | + expect(parseWidth("643")).toEqual(643); |
| 23 | + }); |
| 24 | +}); |
| 25 | + |
| 26 | +describe("Hex color validator", () => { |
| 27 | + it("should return true", () => { |
| 28 | + expect(isHexColor("#fff")).toEqual(true); |
| 29 | + }); |
| 30 | + |
| 31 | + it("should return true", () => { |
| 32 | + expect(isHexColor("#fffaaa")).toEqual(true); |
| 33 | + }); |
| 34 | + |
| 35 | + it("should return true", () => { |
| 36 | + expect(isHexColor("#000fff")).toEqual(true); |
| 37 | + }); |
| 38 | + |
| 39 | + it("should return false", () => { |
| 40 | + expect(isHexColor("#ffff")).toEqual(false); |
| 41 | + }); |
| 42 | + |
| 43 | + it("should return false", () => { |
| 44 | + expect(isHexColor("#fffff")).toEqual(false); |
| 45 | + }); |
| 46 | + |
| 47 | + it("should return false", () => { |
| 48 | + expect(isHexColor("ffffff")).toEqual(false); |
| 49 | + }); |
| 50 | +}); |
0 commit comments