From 71c1f87b592db756d49dac7bbfcfb7b69a92087d Mon Sep 17 00:00:00 2001 From: tooooo1 Date: Sat, 23 Sep 2023 08:55:05 +0900 Subject: [PATCH] refactor: move root test file extractColors --- .../image/src/{__test__ => }/extractColors.test.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename packages/image/src/{__test__ => }/extractColors.test.ts (69%) diff --git a/packages/image/src/__test__/extractColors.test.ts b/packages/image/src/extractColors.test.ts similarity index 69% rename from packages/image/src/__test__/extractColors.test.ts rename to packages/image/src/extractColors.test.ts index 534b7e7..679f7bd 100644 --- a/packages/image/src/__test__/extractColors.test.ts +++ b/packages/image/src/extractColors.test.ts @@ -1,9 +1,9 @@ import { describe, expect, it } from "vitest"; -import { extractColors } from ".."; +import { extractColors } from "."; describe("extractColors function", () => { it("should return an array of colors", async () => { - const result = await extractColors("src/__test__/images/test.png", { + const result = await extractColors("src/images/test.png", { quality: 10, }); expect(result.length).toBeGreaterThan(0); @@ -11,7 +11,7 @@ describe("extractColors function", () => { it("should return limited number of colors when colorCount is provided", async () => { const colorCount = 5; - const result = await extractColors("src/__test__/images/test.png", { + const result = await extractColors("src/images/test.png", { quality: 10, colorCount, }); @@ -20,21 +20,21 @@ describe("extractColors function", () => { it("should throw an error if quality is out of range", async () => { await expect( - extractColors("src/__test__/images/test.png", { quality: 101 }), + extractColors("src/images/test.png", { quality: 101 }), ).rejects.toThrow("Quality should be between 1 and 100"); await expect( - extractColors("src/__test__/images/test.png", { quality: 0 }), + extractColors("src/images/test.png", { quality: 0 }), ).rejects.toThrow("Quality should be between 1 and 100"); }); it("should filter out pixels with opacity less than 125", async () => { - const result = await extractColors("src/__test__/images/test.png"); + const result = await extractColors("src/images/test.png"); const hasTransparentPixel = result.some(([, , , a]) => a < 125); expect(hasTransparentPixel).toBe(false); }); it("should filter out almost white pixels", async () => { - const result = await extractColors("src/__test__/images/test.png"); + const result = await extractColors("src/images/test.png"); const hasWhitePixel = result.some( ([r, g, b]) => r > 250 && g > 250 && b > 250, );