Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

46 linesCodeBlameRaw
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { iso, isoPath, pts, stagger, timing } from "./art.ts";
5
6test("iso projects the floor axes and lifts by z", () => {
7 assert.deepEqual(iso(0, 0), [0, 0]);
8 const [x, y] = iso(10, 0);
9 assert.ok(Math.abs(x - 8.660254) < 1e-5);
10 assert.equal(y, 5);
11 assert.deepEqual(iso(0, 0, 7), [0, -7]);
12 // Equal steps along x and y cancel sideways.
13 assert.equal(iso(4, 4)[0], 0);
14});
15
16test("pts and isoPath round to one decimal place", () => {
17 assert.equal(
18 pts([
19 [1.234, 5.678],
20 [0, 0],
21 ]),
22 "1.2,5.7 0.0,0.0",
23 );
24 assert.equal(
25 isoPath(
26 [
27 [0, 0],
28 [10, 0],
29 ],
30 2,
31 ),
32 "M0.0 -2.0 L8.7 3.0",
33 );
34});
35
36test("stagger spreads starts evenly inside the loop", () => {
37 assert.deepEqual(stagger(4, 8), ["0s", "2s", "4s", "6s"]);
38 assert.deepEqual(stagger(3, 4, 1), ["1s", "2s", "3s"]);
39 assert.deepEqual(stagger(0, 5), []);
40 assert.deepEqual(stagger(3, 1), ["0s", "0.33s", "0.67s"]);
41});
42
43test("timing names the custom properties the stylesheet reads", () => {
44 assert.deepEqual(timing(6, 1.5), { "--dur": "6s", "--delay": "1.5s" });
45 assert.deepEqual(timing(3.333, "2s"), { "--dur": "3.33s", "--delay": "2s" });
46});