pr_01m47d15m3e54sn21z27rpy5n9/apps/web/app/lib/art.test.ts

31 lines1,177 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1import 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(pts([[1.234, 5.678], [0, 0]]), "1.2,5.7 0.0,0.0");
18 assert.equal(isoPath([[0, 0], [10, 0]], 2), "M0.0 -2.0 L8.7 3.0");
19});
20
21test("stagger spreads starts evenly inside the loop", () => {
22 assert.deepEqual(stagger(4, 8), ["0s", "2s", "4s", "6s"]);
23 assert.deepEqual(stagger(3, 4, 1), ["1s", "2s", "3s"]);
24 assert.deepEqual(stagger(0, 5), []);
25 assert.deepEqual(stagger(3, 1), ["0s", "0.33s", "0.67s"]);
26});
27
28test("timing names the custom properties the stylesheet reads", () => {
29 assert.deepEqual(timing(6, 1.5), { "--dur": "6s", "--delay": "1.5s" });
30 assert.deepEqual(timing(3.333, "2s"), { "--dur": "3.33s", "--delay": "2s" });
31});