Skip to content

Commit

Permalink
Update tests for SaptuneDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
EMaksy committed Sep 27, 2023
1 parent 8272d61 commit fa43bac
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import SaptuneDetails from './SaptuneDetails';

const { hostname, id: hostID } = hostFactory.build();
const {
package_version: packageVersion,
configured_version: configuredVersion,
tuning_state: tuningState,
applied_notes: appliedNotes,
applied_solution: appliedSolution,
configured_version: configuredVersion,
enabled_solution: enabledSolution,
enabled_notes: enabledNotes,
package_version: packageVersion,
services,
staging,
tuning_state: tuningState,
} = saptuneStatusFactory.build();

function ContainerWrapper({ children }) {
Expand Down
16 changes: 14 additions & 2 deletions assets/js/components/SaptuneDetails/SaptuneDetails.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,31 @@ import SaptuneDetails from './SaptuneDetails';
describe('SaptuneDetails', () => {
it('should render the details correctly', () => {
const {
applied_notes: appliedNotes,
applied_solution: appliedSolution,
configured_version: configuredVersion,
enabled_solution: enabledSolution,
enabled_notes: enabledNotes,
package_version: packageVersion,
services,
staging,
tuning_state: tuningState,
} = saptuneStatusFactory.build();

const { hostname, id: hostID } = hostFactory.build();

renderWithRouter(
<SaptuneDetails
packageVersion={packageVersion}
appliedNotes={appliedNotes}
appliedSolution={appliedSolution}
configuredVersion={configuredVersion}
enabledNotes={enabledNotes}
enabledSolution={enabledSolution}
hostname={hostname}
hostID={hostID}
configuredVersion={configuredVersion}
packageVersion={packageVersion}
services={services}
staging={staging}
tuningState={tuningState}
/>
);
Expand Down
11 changes: 7 additions & 4 deletions assets/js/lib/test-utils/factories/hosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ const saptuneServiceEnabledEnum = () =>
const saptuneServiceNameEnum = () =>
faker.helpers.arrayElement(['tuned', 'sapconf', 'saptune']);

const saptuneSolutionNameEnum = () =>
faker.helpers.arrayElement(['NETWEAVER', 'HANA', 'NETWEAVER+HANA']);

const saptuneServiceFactory = Factory.define(() => ({
active: saptuneServiceActiveEnum(),
enabled: saptuneServiceEnabledEnum(),
Expand All @@ -63,8 +66,8 @@ const saptuneServiceFactory = Factory.define(() => ({

const saptuneStagingFactory = Factory.define(() => ({
enabled: faker.datatype.boolean(),
notes: [],
solutions_ids: [],
notes: saptuneNotesIDs,
solutions_ids: saptuneNotesIDs,
}));

const saptuneAppliedNotesFactory = Factory.define(() => ({
Expand All @@ -74,7 +77,7 @@ const saptuneAppliedNotesFactory = Factory.define(() => ({

const saptuneAppliedSolutionFactory = Factory.define(() => ({
notes: saptuneNotesIDs.map((id) => id),
id: 'NETWEAVER',
id: saptuneSolutionNameEnum(),
partial: faker.datatype.boolean(),
}));

Expand All @@ -84,7 +87,7 @@ const saptuneEnabledNotesFactory = Factory.define(() => ({
}));

const saptuneEnabledSolutionsFactory = Factory.define(() => ({
id: 'NETWEAVER',
id: saptuneSolutionNameEnum(),
notes: saptuneNotesIDs.map((id) => id),
partial: faker.datatype.boolean(),
}));
Expand Down

0 comments on commit fa43bac

Please sign in to comment.