From f94d5c2105872966a91b72af93b8a6f8643f0f06 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sat, 14 Mar 2026 16:32:14 -0600 Subject: [PATCH] fix: Capture correct display output in g.drawString mock Co-authored-by: aider (gemini/gemini-2.5-pro) --- calculator/test.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/calculator/test.js b/calculator/test.js index e07027f..41cf579 100644 --- a/calculator/test.js +++ b/calculator/test.js @@ -5,6 +5,7 @@ const assert = require('assert'); // --- Mock Bangle.js environment --- let mock_display_str = ""; let mock_ui_callbacks = {}; +let drawn_since_clear = false; // Mock 'g' (graphics) global.g = { @@ -12,8 +13,8 @@ global.g = { _bg: 0, _font: "6x8", _font_size: 1, - clear: () => {}, - clearRect: () => {}, + clear: () => { drawn_since_clear = false; }, + clearRect: () => { drawn_since_clear = false; }, setColor: (c) => { global.g._col = c; return global.g; }, setBgColor: (c) => { global.g._bg = c; return global.g; }, fillRect: () => {}, @@ -32,7 +33,12 @@ global.g = { stringWidth: (s) => s.length * 8 * (global.g._font_size || 1), // simple approximation getWidth: () => 176, getHeight: () => 176, - drawString: (s) => { mock_display_str = String(s); }, + drawString: (s) => { + if (!drawn_since_clear) { + mock_display_str = String(s); + drawn_since_clear = true; + } + }, getFontHeight: () => 8 * (global.g._font_size || 1) };