fix: Capture correct display output in g.drawString mock

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2026-03-14 16:32:14 -06:00
committed by Tanner
parent 913156ca3c
commit f94d5c2105
+9 -3
View File
@@ -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)
};