From 25e45b29fe4356462c1fad8e814d28642b57ee4c Mon Sep 17 00:00:00 2001 From: Zak Burke Date: Mon, 10 Jun 2024 08:26:43 -0400 Subject: [PATCH] test DISCOVERY_APPLICATIONS --- src/discoverServices.js | 4 +--- src/discoverServices.test.js | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/discoverServices.js b/src/discoverServices.js index 405fbe18a..98e6a4c43 100644 --- a/src/discoverServices.js +++ b/src/discoverServices.js @@ -258,9 +258,7 @@ export function discoveryReducer(state = {}, action) { ...action.data.uiModules.map((d) => { return { name: d.id, - interfaces: d.provides?.map((i) => { - return { name: i.id + ' ' + i.version }; - }) || [], + interfaces: [], }; }) diff --git a/src/discoverServices.test.js b/src/discoverServices.test.js index c6cd08fbf..9afabedc8 100644 --- a/src/discoverServices.test.js +++ b/src/discoverServices.test.js @@ -98,6 +98,42 @@ describe('discoverServices', () => { }); describe('discoveryReducer', () => { + it('handles DISCOVERY_APPLICATIONS', () => { + let state = {}; + const moduleDescriptors = [ + { id: 'mod-a' }, + { id: 'mod-b' }, + ]; + const uiModules = [ + { id: 'folio_c' }, + { id: 'folio_d' }, + ]; + const action = { + type: 'DISCOVERY_APPLICATIONS', + data: { + id: 'a', + moduleDescriptors, + uiModules, + }, + }; + + const mapped = { + applications: { + [action.data.id]: { + name: action.data.id, + modules: [ + ...moduleDescriptors.map((d) => ({ name: d.id, interfaces: [] })), + ...uiModules.map((d) => ({ name: d.id, interfaces: [] })), + ], + }, + }, + }; + + state = discoveryReducer(state, action); + + expect(state).toMatchObject(mapped); + }); + it('handles DISCOVERY_OKAPI', () => { let state = { okapi: '0.0.0'