mirror of
https://github.com/Ku6epXBOCTuK/easy-png-tools.git
synced 2026-11-14 17:38:19 +00:00
chore: clear lint rules warns: comments, tests
This commit is contained in:
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
import { COMPRESSION_LEVELS, findMaxColorsWithin } from "./compress";
|
||||
|
||||
describe("COMPRESSION_LEVELS", () => {
|
||||
it("пресеты упорядочены по убыванию цветов", () => {
|
||||
it("presets ordered by descending colors", () => {
|
||||
const values = Object.values(COMPRESSION_LEVELS);
|
||||
for (let i = 1; i < values.length; i++)
|
||||
expect(values[i - 1]).toBeGreaterThan(values[i]);
|
||||
@@ -10,26 +10,26 @@ describe("COMPRESSION_LEVELS", () => {
|
||||
});
|
||||
|
||||
describe("findMaxColorsWithin", () => {
|
||||
const sizeOf = (k: number) => 1000 + k * 100; // размер растёт с k
|
||||
const sizeOf = (k: number) => 1000 + k * 100; // size grows with k
|
||||
|
||||
it("подбирает максимум k, укладывающийся в цель", async () => {
|
||||
// target 5200 → подходит k≤42 → ожидаем 42 при maxK≥42
|
||||
it("picks max k fitting the target", async () => {
|
||||
// target 5200 -> k<=42 fits -> expect 42 at maxK>=42
|
||||
const k = await findMaxColorsWithin(5200, 256, async (kk) => sizeOf(kk));
|
||||
expect(k).toBeGreaterThanOrEqual(40);
|
||||
expect(sizeOf(k)).toBeLessThanOrEqual(5200);
|
||||
});
|
||||
|
||||
it("цель достигается даже на минимуме — возвращает 2", async () => {
|
||||
it("target unreachable even at minimum - returns 2", async () => {
|
||||
const k = await findMaxColorsWithin(50, 256, async (kk) => sizeOf(kk));
|
||||
expect(k).toBe(2);
|
||||
});
|
||||
|
||||
it("encodeSize null трактуется как провал", async () => {
|
||||
it("encodeSize null treated as failure", async () => {
|
||||
const k = await findMaxColorsWithin(999999, 16, async () => null);
|
||||
expect(k).toBe(2);
|
||||
});
|
||||
|
||||
it("бинарный поиск сходится быстрее полного перебора", async () => {
|
||||
it("binary search converges faster than full scan", async () => {
|
||||
let calls = 0;
|
||||
await findMaxColorsWithin(30000, 256, async (kk) => {
|
||||
calls++;
|
||||
|
||||
Reference in New Issue
Block a user