mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Fix for unit test failure in jt detail test where getting instance groups wasn't mocked (#296)
Fix for unit test failure in jt detail test where getting instance groups wasn't mocked.
This commit is contained in:
parent
5e6562023d
commit
0a6fc8cb89
@ -5,12 +5,12 @@ import { CardBody, Button, TextList, TextListItem, TextListItemVariants, TextLis
|
||||
import styled from 'styled-components';
|
||||
import { t } from '@lingui/macro';
|
||||
|
||||
import ContentError from '../../../components/ContentError';
|
||||
import ContentLoading from '../../../components/ContentLoading';
|
||||
import { ChipGroup, Chip } from '../../../components/Chip';
|
||||
import { DetailList, Detail } from '../../../components/DetailList';
|
||||
import { JobTemplatesAPI } from '../../../api';
|
||||
import { toTitleCase } from '../../../util/strings';
|
||||
import ContentError from '@components/ContentError';
|
||||
import ContentLoading from '@components/ContentLoading';
|
||||
import { ChipGroup, Chip } from '@components/Chip';
|
||||
import { DetailList, Detail } from '@components/DetailList';
|
||||
import { JobTemplatesAPI } from '@api';
|
||||
import { toTitleCase } from '@util/strings';
|
||||
|
||||
const ButtonGroup = styled.div`
|
||||
display: flex;
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
import React from 'react';
|
||||
import { mountWithContexts, waitForElement } from '../../../../testUtils/enzymeHelpers';
|
||||
import { mountWithContexts, waitForElement } from '@testUtils/enzymeHelpers';
|
||||
import JobTemplateDetail, { _JobTemplateDetail } from './JobTemplateDetail';
|
||||
import { JobTemplatesAPI } from '@api';
|
||||
|
||||
jest.mock('@api');
|
||||
|
||||
describe('<JobTemplateDetail />', () => {
|
||||
const template = {
|
||||
@ -38,6 +41,14 @@ describe('<JobTemplateDetail />', () => {
|
||||
|
||||
const readInstanceGroups = jest.spyOn(_JobTemplateDetail.prototype, 'readInstanceGroups');
|
||||
|
||||
beforeEach(() => {
|
||||
JobTemplatesAPI.readInstanceGroups.mockResolvedValue(mockInstanceGroups);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
test('initially renders succesfully', () => {
|
||||
const wrapper = mountWithContexts(
|
||||
<JobTemplateDetail
|
||||
@ -55,6 +66,7 @@ describe('<JobTemplateDetail />', () => {
|
||||
await waitForElement(wrapper, 'JobTemplateDetail', (el) => el.state('hasContentLoading') === true);
|
||||
expect(readInstanceGroups).toHaveBeenCalled();
|
||||
await waitForElement(wrapper, 'JobTemplateDetail', (el) => el.state('hasContentLoading') === false);
|
||||
expect(JobTemplatesAPI.readInstanceGroups).toHaveBeenCalledTimes(1);
|
||||
done();
|
||||
});
|
||||
test('Edit button is absent when user does not have edit privilege', async (done) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user