add test for conditional show/hide of schedules tab for project detail view

This commit is contained in:
John Mitchell 2020-02-27 15:20:50 -05:00
parent 4db3e823bf
commit 989ef3538e
2 changed files with 43 additions and 2 deletions

View File

@ -184,8 +184,6 @@ class Project extends Component {
);
}
console.log(project);
return (
<PageSection>
<Card>

View File

@ -68,6 +68,49 @@ describe('<Project />', () => {
done();
});
test('schedules tab shown for scm based projects.', async done => {
ProjectsAPI.readDetail.mockResolvedValue({ data: mockDetails });
OrganizationsAPI.read.mockResolvedValue({
count: 0,
next: null,
previous: null,
data: { results: [] },
});
const wrapper = mountWithContexts(
<Project setBreadcrumb={() => {}} me={mockMe} />
);
const tabs = await waitForElement(
wrapper,
'.pf-c-tabs__item',
el => el.length === 4
);
expect(tabs.at(3).text()).toEqual('Schedules');
done();
});
test('schedules tab hidden for manual projects.', async done => {
const manualDetails = Object.assign(mockDetails, { scm_type: '' });
ProjectsAPI.readDetail.mockResolvedValue({ data: manualDetails });
OrganizationsAPI.read.mockResolvedValue({
count: 0,
next: null,
previous: null,
data: { results: [] },
});
const wrapper = mountWithContexts(
<Project setBreadcrumb={() => {}} me={mockMe} />
);
const tabs = await waitForElement(
wrapper,
'.pf-c-tabs__item',
el => el.length === 3
);
tabs.forEach(tab => expect(tab.text()).not.toEqual('Schedules'));
done();
});
test('should show content error when user attempts to navigate to erroneous route', async () => {
const history = createMemoryHistory({
initialEntries: ['/projects/1/foobar'],