Skip to content

Commit

Permalink
test DISCOVERY_APPLICATIONS
Browse files Browse the repository at this point in the history
  • Loading branch information
zburke committed Jun 10, 2024
1 parent 72bfe6b commit 25e45b2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/discoverServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
};
})

Expand Down
36 changes: 36 additions & 0 deletions src/discoverServices.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 25e45b2

Please sign in to comment.