From 932264124c3c75aa24c44e771b7633d5f7af598e Mon Sep 17 00:00:00 2001 From: teahubxyz Date: Mon, 19 Oct 2026 19:10:11 +0000 Subject: [PATCH] havre: tests for rewriting a shot and the tempo of moves Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BQqGFv54JJTw7p3rgGjP7C --- ventures/havre/tests/shot.test.mjs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 ventures/havre/tests/shot.test.mjs diff --git a/ventures/havre/tests/shot.test.mjs b/ventures/havre/tests/shot.test.mjs new file mode 100644 index 0000000..a65c388 --- /dev/null +++ b/ventures/havre/tests/shot.test.mjs @@ -0,0 +1,23 @@ +// node --test tests/*.test.mjs: a shot written again (to an instruction, or different), and how often they move +import { test } from "node:test"; +import assert from "node:assert/strict"; +import * as A from "../abilities.js"; + +const card = { name: "Odile", tagline: "Keeps the light.", look: { description: "white hair" } }; +const said = (msgs) => msgs.at(-1).content; + +test("a shot written again keeps the instruction, or asks for a different one", () => { + assert.doesNotMatch(said(A.shotMessages(card, [], "")), /as it stands|last shot/); + const changed = said(A.shotMessages(card, [], "", "photo", { current: "Odile on the wall at dawn.", change: "make it funnier" })); + assert.match(changed, /The shot as it stands:\nOdile on the wall at dawn\./); + assert.match(changed, /Change it: make it funnier\./); + const other = said(A.shotMessages(card, [], "", "photo", { current: "Odile on the wall at dawn." })); + assert.match(other, /clearly different/); +}); + +test("tempo: never moves unasked, every round always may", () => { + const h = [{ role: "user", content: "hi" }, { role: "assistant", content: "Hello there." }]; + assert.equal(A.moveLikely(h, { every: 0 }), false); + assert.equal(A.moveLikely([{ role: "user", content: "send me a photo" }, { role: "assistant", content: "ok" }], { every: 0 }), true); + assert.equal(A.moveLikely(h, { every: 1 }), true); +});