From 4235885541887466954a606f1bfd3c490da88fcc Mon Sep 17 00:00:00 2001 From: Gianluca Zuccarelli Date: Tue, 17 Dec 2024 11:50:20 +0000 Subject: [PATCH] test/mocks: add cockpit lib mocks Add some stub functions for the cockpit library, these will be needed for tests to pass and for stubbing out the library for the service. --- src/test/mocks/cockpit/fsinfo.ts | 17 +++++++++++++++++ src/test/mocks/cockpit/index.ts | 25 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/test/mocks/cockpit/fsinfo.ts create mode 100644 src/test/mocks/cockpit/index.ts diff --git a/src/test/mocks/cockpit/fsinfo.ts b/src/test/mocks/cockpit/fsinfo.ts new file mode 100644 index 00000000..16779038 --- /dev/null +++ b/src/test/mocks/cockpit/fsinfo.ts @@ -0,0 +1,17 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ + +type fileinfo = { + entries?: Record; +}; + +export const fsinfo = ( + path: string, + attributes: (keyof fileinfo)[], + options: object +): Promise => { + return new Promise((resolve) => { + resolve({ + entries: {}, + }); + }); +}; diff --git a/src/test/mocks/cockpit/index.ts b/src/test/mocks/cockpit/index.ts new file mode 100644 index 00000000..fa6b414a --- /dev/null +++ b/src/test/mocks/cockpit/index.ts @@ -0,0 +1,25 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ + +type userinfo = { + home: string; +}; + +export default { + user: (): Promise => { + return new Promise((resolve) => { + resolve({ + home: '', + }); + }); + }, + file: (path: string) => { + return { + read: (): Promise => { + return new Promise((resolve) => { + resolve(''); + }); + }, + close: () => {}, + }; + }, +};