fix(deploy): pin distinct image tags per compose (booklib/{api,web}:{dev,prod}); same project name shared default tags so dev up without --build ran the prod image
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { PageHeights } from "../src/lib/virt";
|
||||
|
||||
it("估算高度:offset/total/pageAt/range(带 overscan、夹边)", () => {
|
||||
const ph = new PageHeights(10, 100);
|
||||
expect(ph.offset(3)).toBe(300);
|
||||
expect(ph.total()).toBe(1000);
|
||||
expect(ph.pageAt(350)).toBe(3);
|
||||
expect(ph.pageAt(-10)).toBe(0);
|
||||
expect(ph.pageAt(99_999)).toBe(9);
|
||||
expect(ph.range(0, 100, 2)).toEqual([0, 3]);
|
||||
expect(ph.range(950, 100, 2)).toEqual([7, 10]);
|
||||
});
|
||||
|
||||
it("set 修正高度并平移后续 offset;返回增量;幂等", () => {
|
||||
const ph = new PageHeights(10, 100);
|
||||
expect(ph.set(2, 150)).toBe(50);
|
||||
expect(ph.offset(2)).toBe(200); // 自身 offset 不受自己影响
|
||||
expect(ph.offset(3)).toBe(350); // 后续整体 +50
|
||||
expect(ph.total()).toBe(1050);
|
||||
expect(ph.pageAt(349)).toBe(2);
|
||||
expect(ph.pageAt(351)).toBe(3);
|
||||
expect(ph.set(2, 150)).toBe(0);
|
||||
});
|
||||
|
||||
it("n=0 时一切归空", () => {
|
||||
const ph = new PageHeights(0, 100);
|
||||
expect(ph.total()).toBe(0);
|
||||
expect(ph.range(0, 100, 2)).toEqual([0, 0]);
|
||||
expect(ph.set(0, 50)).toBe(0);
|
||||
});
|
||||
Reference in New Issue
Block a user