feat: allow mocking of getListObject (#1745)

This commit is contained in:
Christian Veinfors
2025-05-14 08:17:44 +02:00
committed by GitHub
parent bfb15f5eb1
commit 72fef8889f
2 changed files with 25 additions and 1 deletions

View File

@@ -341,4 +341,28 @@ describe('enigma-mocker', () => {
});
});
});
describe('getListObject', () => {
test('should return a model that maps to corresponding genericObject', async () => {
const app = await createEnigmaMocker([
{
getLayout: {
qInfo: { qId: 'TestList' },
qAppObjectList: {
qItems: [],
},
},
},
]);
const listObjectModel = await app.getListObject({ qInfo: { qId: 'TestList' } });
expect(listObjectModel.id).toEqual('TestList');
});
test('should return undefined if no mock exist', async () => {
const app = await createEnigmaMocker(genericObjects);
const listObjectModel = await app.getListObject({ qInfo: { qId: 'TestList' } });
expect(listObjectModel).toBe(undefined);
});
});
});

View File

@@ -16,7 +16,7 @@ export default function fromGenericObjects(genericObjects, options = {}) {
destroySessionObject: async () => {},
getObject,
getAppLayout,
getListObject: async () => {},
getListObject: async (props) => getObject(props.qInfo?.qId),
};
return Promise.resolve(app);