test(phase6): align behavioural harness with client wrappers

This commit is contained in:
2026-03-25 10:07:25 +00:00
parent 480897bdc0
commit 7d2f8a2c27
2 changed files with 47 additions and 0 deletions
+20
View File
@@ -72,6 +72,24 @@ const loadServiceModule = (fileName, injected = {}) => {
source = source.replace(/export const\s+/g, "const ");
source += `\nmodule.exports = { ${exportNames.join(", ")} };\n`;
const defaultGetJson = (url, config) => {
if (!injected.axios || !injected.axios.get) {
throw new Error("Missing axios.get for default getJson mock");
}
return injected.axios
.get(url, config)
.then((response) => response.data);
};
const defaultRequestJson = (config) => {
if (!injected.axios) {
throw new Error("Missing axios for default requestJson mock");
}
return injected.axios(config).then((response) => response.data);
};
const context = {
module: { exports: {} },
exports: {},
@@ -85,6 +103,8 @@ const loadServiceModule = (fileName, injected = {}) => {
warn: () => {},
error: () => {}
},
getJson: injected.getJson || defaultGetJson,
requestJson: injected.requestJson || defaultRequestJson,
...injected
};