fix: Expose buttonPress function for testing
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
+5
-3
@@ -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: () => {} };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user