fix: Expose buttonPress function for testing

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2026-03-14 16:30:04 -06:00
committed by Tanner
parent a5adeb379c
commit 913156ca3c
+5 -3
View File
@@ -57,10 +57,12 @@ global.load = () => {};
// --- Load calculator app --- // --- Load calculator app ---
// We wrap the app code in a function that returns the buttonPress function,
// so we can capture it and use it in our tests.
const calculatorCode = fs.readFileSync(path.join(__dirname, 'calculator.app.js'), 'utf8'); const calculatorCode = fs.readFileSync(path.join(__dirname, 'calculator.app.js'), 'utf8');
(function(require) { const wrappedCode = `(function(require) { ${calculatorCode}; return buttonPress; })`;
eval(calculatorCode); const getButtonPress = eval(wrappedCode);
})((name) => { const buttonPress = getButtonPress((name) => {
if (name === "FontDylex7x13") { if (name === "FontDylex7x13") {
return { add: () => {} }; return { add: () => {} };
} }