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:
+9
-3
@@ -5,6 +5,7 @@ const assert = require('assert');
|
|||||||
// --- Mock Bangle.js environment ---
|
// --- Mock Bangle.js environment ---
|
||||||
let mock_display_str = "";
|
let mock_display_str = "";
|
||||||
let mock_ui_callbacks = {};
|
let mock_ui_callbacks = {};
|
||||||
|
let drawn_since_clear = false;
|
||||||
|
|
||||||
// Mock 'g' (graphics)
|
// Mock 'g' (graphics)
|
||||||
global.g = {
|
global.g = {
|
||||||
@@ -12,8 +13,8 @@ global.g = {
|
|||||||
_bg: 0,
|
_bg: 0,
|
||||||
_font: "6x8",
|
_font: "6x8",
|
||||||
_font_size: 1,
|
_font_size: 1,
|
||||||
clear: () => {},
|
clear: () => { drawn_since_clear = false; },
|
||||||
clearRect: () => {},
|
clearRect: () => { drawn_since_clear = false; },
|
||||||
setColor: (c) => { global.g._col = c; return global.g; },
|
setColor: (c) => { global.g._col = c; return global.g; },
|
||||||
setBgColor: (c) => { global.g._bg = c; return global.g; },
|
setBgColor: (c) => { global.g._bg = c; return global.g; },
|
||||||
fillRect: () => {},
|
fillRect: () => {},
|
||||||
@@ -32,7 +33,12 @@ global.g = {
|
|||||||
stringWidth: (s) => s.length * 8 * (global.g._font_size || 1), // simple approximation
|
stringWidth: (s) => s.length * 8 * (global.g._font_size || 1), // simple approximation
|
||||||
getWidth: () => 176,
|
getWidth: () => 176,
|
||||||
getHeight: () => 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)
|
getFontHeight: () => 8 * (global.g._font_size || 1)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user