src/test/mocks: add cockpit mocks

Adds `mtime` tot fsinfo, and `replace` to `cockpit.file`.
This commit is contained in:
Sanne Raymaekers 2025-01-23 16:27:09 +01:00
parent c8c62dda9d
commit 75eb0afd10
2 changed files with 13 additions and 0 deletions

View file

@ -2,6 +2,7 @@
type fileinfo = {
entries?: Record<string, fileinfo>;
mtime: number;
};
export const fsinfo = (
@ -12,6 +13,7 @@ export const fsinfo = (
return new Promise((resolve) => {
resolve({
entries: {},
mtime: 1,
});
});
};

View file

@ -20,6 +20,7 @@ export default {
});
},
close: () => {},
replace: (contents: string) => {},
};
},
spawn: (args: string[], attributes: object): Promise<string | Uint8Array> => {
@ -27,4 +28,14 @@ export default {
resolve('');
});
},
http: (address: string, options: object) => {
return {
get: (path?: string, headers?: object): string => {
return '';
},
post: (path: string, data: object, headers?: object): string => {
return '';
},
};
},
};