Files
ausboss-ComfyUI-AusBoss/tests/picture_steps.test.mjs
ausboss bf2f75d487 Compare and Save Image: step through several pictures
A list of pictures runs these nodes once per picture, and the panels
only showed one of them (#204). Arrows (2 / 5) now appear on the node
when a run brings more than one picture: Compare steps through its
pairs, A and B together, and Erase saves the pair on screen. The shared
preview panel gets the same arrows, so Save Image, Mask Refine, Mask by
Name, LaMa Inpaint and Select Frame step through their results. A node
too narrow for the arrows widens to fit while they show.
2026-10-18 17:50:53 +00:00

29 lines
994 B
JavaScript

import assert from "node:assert/strict";
import test from "node:test";
import { keepIndex, stepIndex, stepperLabel } from "../js/shared/picture_steps.mjs";
test("a new run keeps the picture that was showing, if it still has one", () => {
assert.equal(keepIndex(1, 3), 1);
assert.equal(keepIndex(4, 3), 2);
assert.equal(keepIndex(-2, 3), 0);
assert.equal(keepIndex(Number.NaN, 3), 0);
assert.equal(keepIndex(2, 0), 0);
});
test("the arrows step one picture and go round at the ends", () => {
assert.equal(stepIndex(0, 3, 1), 1);
assert.equal(stepIndex(2, 3, 1), 0);
assert.equal(stepIndex(0, 3, -1), 2);
assert.equal(stepIndex(1, 3, 0), 1);
assert.equal(stepIndex(0, 1, 1), 0);
assert.equal(stepIndex(0, 0, 1), 0);
});
test("the label counts from one and is empty for a single picture", () => {
assert.equal(stepperLabel(0, 3), "1 / 3");
assert.equal(stepperLabel(5, 3), "3 / 3");
assert.equal(stepperLabel(0, 1), "");
assert.equal(stepperLabel(0, 0), "");
});