Skip to content

Commit

Permalink
Add basic test to see correct cluster type is used
Browse files Browse the repository at this point in the history
  • Loading branch information
arbulu89 committed May 25, 2023
1 parent c707f1e commit a6abc84
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions assets/js/components/ClusterDetails/ClusterDetailsPage.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';

import { screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import { withState, renderWithRouterMatch } from '@lib/test-utils';

import { clusterFactory } from '@lib/test-utils/factories';

import { ClusterDetailsPage } from './ClusterDetailsPage';

describe('ClusterDetails ClusterDetailsPage component', () => {
it.each([
{ type: 'hana_scale_up', label: 'HANA scale-up' },
{ type: 'ascs_ers', label: 'ASCS/ERS' },
{ type: 'unknwon', label: 'Unknown cluster type' },
])('should display the $type details based on cluster type', ({ type, label }) => {
const cluster = clusterFactory.build({ type })
const initialState = {
clustersList: { clusters: [cluster] },
hostsList: { hosts: []},
lastExecutions: {
[cluster.id]: { data: null, loading: false, error: null}
}
};

const [statefulClusterDetailsPage, _] = withState(
<ClusterDetailsPage />,
initialState
);

renderWithRouterMatch(statefulClusterDetailsPage, {
path: 'clusters/:clusterID',
route: `/clusters/${cluster.id}`,
});

expect(screen.getByText(label)).toBeInTheDocument();
});
});

0 comments on commit a6abc84

Please sign in to comment.