Skip to content

Commit

Permalink
increase coverage
Browse files Browse the repository at this point in the history
Signed-off-by: at670475 <andrea.tabone@broadcom.com>
  • Loading branch information
taban03 committed Jul 24, 2023
1 parent 449ae1d commit 39a99ca
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ export default class ServiceTab extends Component {

handleDialogOpen = (currentService) => {
const { selectedVersion } = this.state;
// eslint-disable-next-line no-console
console.log(selectedVersion);
// eslint-disable-next-line no-console
console.log(currentService);
if (selectedVersion === null) {
this.setState({ previousVersion: currentService.defaultApiVersion });
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,14 @@ describe('>>> ServiceVersionDiff component tests', () => {
serviceVersionDiff.find('[data-testid="diff-button"]').first().simulate('click');
expect(getDiff.mock.calls.length).toBe(1);
});

it('Should call getDiff when default version', () => {
const getDiff = jest.fn();
const serviceVersionDiff = shallow(
<ServiceVersionDiff getDiff={getDiff} serviceId="service" versions={['v1', 'v2']} version2="v2" />
);

serviceVersionDiff.find('[data-testid="diff-button"]').first().simulate('click');
expect(getDiff.mock.calls.length).toBe(1);
});
});
12 changes: 12 additions & 0 deletions api-catalog-ui/frontend/src/utils/utilFunctions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe('>>> Util Functions tests', () => {
<div id="refresh-api-button">
<span class="MuiIconButton-label"></span>
</div>
<p id="tileLabel"></p>
`;
});

Expand Down Expand Up @@ -119,6 +120,7 @@ describe('>>> Util Functions tests', () => {
const wizardButton = document.querySelector('#onboard-wizard-button > span.MuiButton-label');
const refreshButton = document.querySelector('#refresh-api-button > span.MuiIconButton-label');
const link = document.querySelector("link[rel~='icon']");
const tileLabel = document.querySelector('p#tileLabel');
expect(link.href).toContain('img-url');
expect(header.style.getPropertyValue('background-color')).toBe('white');
expect(title.style.getPropertyValue('color')).toBe('black');
Expand All @@ -127,9 +129,19 @@ describe('>>> Util Functions tests', () => {
expect(swaggerLabel.style.getPropertyValue('color')).toBe('black');
expect(wizardButton.style.getPropertyValue('color')).toBe('black');
expect(refreshButton.style.getPropertyValue('color')).toBe('black');
expect(tileLabel.style.getPropertyValue('font-family')).toBe('Arial');
expect(document.documentElement.style.backgroundColor).toBe('blue');
// Clean up the mocks
jest.restoreAllMocks();
global.fetch.mockRestore();
});

it('should return network error when fetching image', async () => {
const uiConfig = {
logo: '/wrong-path/img.png',
};

global.fetch = () => Promise.resolve({ ok: false, status: 404 });
await expect(customUIStyle(uiConfig)).rejects.toThrow('Network response was not ok');
});
});

0 comments on commit 39a99ca

Please sign in to comment.