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 { gradientImage, noiseImage, solidImage } from "./generate";
|
||||
|
||||
describe("solidImage", () => {
|
||||
it("заливает весь холст заданным цветом", () => {
|
||||
it("fills whole canvas with given color", () => {
|
||||
const out = solidImage(2, 2, [10, 20, 30, 255]);
|
||||
expect(out.width).toBe(2);
|
||||
expect([...out.data]).toEqual(new Array(4).fill([10, 20, 30, 255]).flat());
|
||||
@@ -13,25 +13,25 @@ describe("solidImage", () => {
|
||||
[10, 0],
|
||||
[2.5, 10],
|
||||
[-1, 5],
|
||||
])("бросает ошибку на размерах %i x %i", (w, h) => {
|
||||
])("throws on sizes %i x %i", (w, h) => {
|
||||
expect(() => solidImage(w, h, [0, 0, 0, 255])).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("noiseImage", () => {
|
||||
it("детерминирован: одно зерно — одни байты", () => {
|
||||
it("deterministic: same seed - same bytes", () => {
|
||||
expect([...noiseImage(4, 4, 42).data]).toEqual([
|
||||
...noiseImage(4, 4, 42).data,
|
||||
]);
|
||||
});
|
||||
|
||||
it("разные зерна дают разные данные", () => {
|
||||
it("different seeds give different data", () => {
|
||||
const a = [...noiseImage(8, 8, 1).data];
|
||||
const b = [...noiseImage(8, 8, 2).data];
|
||||
expect(a).not.toEqual(b);
|
||||
});
|
||||
|
||||
it("альфа всегда непрозрачная", () => {
|
||||
it("alpha always opaque", () => {
|
||||
const data = noiseImage(3, 3, 7).data;
|
||||
for (let i = 3; i < data.length; i += 4) {
|
||||
expect(data[i]).toBe(255);
|
||||
@@ -40,7 +40,7 @@ describe("noiseImage", () => {
|
||||
});
|
||||
|
||||
describe("gradientImage", () => {
|
||||
it("горизонтальный градиент идёт от цвета A к цвету B", () => {
|
||||
it("horizontal gradient goes from color A to color B", () => {
|
||||
const out = gradientImage(
|
||||
3,
|
||||
1,
|
||||
@@ -54,7 +54,7 @@ describe("gradientImage", () => {
|
||||
expect(px(2)).toEqual([255, 255, 255, 255]);
|
||||
});
|
||||
|
||||
it("вертикальный градиент меняется по строкам", () => {
|
||||
it("vertical gradient changes by rows", () => {
|
||||
const out = gradientImage(
|
||||
1,
|
||||
2,
|
||||
|
||||
Reference in New Issue
Block a user