Skip to content

gitflarePublicPartly agent-ready40

sketch-rush

Multiplayer draw-and-guess game on Cloudflare Workers, Durable Objects and D1.

main
Add the Apache-2.0 licencedbe1e99
JavaScript35 lines1.1 KB
import test from "node:test";import assert from "node:assert/strict";import { PALETTE, WIDTHS, drawSegment } from "../public/render.js";import { createParticles } from "../public/fx.js";import { SOUND_NAMES, createAudio } from "../public/audio.js"; test("palette and widths", () => {  assert.equal(PALETTE.length, 8);  assert.equal(WIDTHS.length, 3);}); test("incremental drawing only issues new segments", () => {  let curves = 0;  const ctx = new Proxy({}, { get: (_, k) => (k === "quadraticCurveTo" ? () => curves++ : () => {}), set: () => true });  const pts = [0, 0, 10, 10, 20, 0, 30, 10];  drawSegment(ctx, pts, 0, "#000", 4);  const full = curves;  curves = 0;  pts.push(40, 0);  drawSegment(ctx, pts, 8, "#000", 4);  assert.ok(curves >= 1 && curves < full + 1);}); test("particles pool", () => {  const p = createParticles();  p.burst(0, 0, 500, 100);  p.update(5);  assert.ok(Array.from(p.life).every((l) => l <= 0));}); test("audio names, safe without context", () => {  for (const n of ["tick", "correct", "close", "turn", "reveal", "win", "pop"]) assert.ok(SOUND_NAMES.includes(n));  createAudio().play("pop");});