Commit 5711ad70 authored by Savas Vedova's avatar Savas Vedova

Implement code review suggestion

parent 2a7944e6
...@@ -92,28 +92,20 @@ describe('Vulnerabilities count list component', () => { ...@@ -92,28 +92,20 @@ describe('Vulnerabilities count list component', () => {
}); });
describe.each` describe.each`
dashboardType | fullPath | expectedContainedQueryVariables dashboardType | provide | expectedContainedQueryVariables
${DASHBOARD_TYPES.INSTANCE} | ${undefined} | ${{ isInstance: true, isGroup: false, isProject: false }} ${DASHBOARD_TYPES.INSTANCE} | ${undefined} | ${{ isInstance: true, isGroup: false, isProject: false }}
${DASHBOARD_TYPES.GROUP} | ${'group/path'} | ${{ isInstance: false, isGroup: true, isProject: false }} ${DASHBOARD_TYPES.GROUP} | ${{ groupFullPath: 'group/path' }} | ${{ isInstance: false, isGroup: true, isProject: false }}
${DASHBOARD_TYPES.PROJECT} | ${'project/path'} | ${{ isInstance: false, isGroup: false, isProject: true }} ${DASHBOARD_TYPES.PROJECT} | ${{ projectFullPath: 'project/path' }} | ${{ isInstance: false, isGroup: false, isProject: true }}
`( `(
'when the dashboard type is $dashboardType', 'when the dashboard type is $dashboardType',
({ dashboardType, fullPath, expectedContainedQueryVariables }) => { ({ dashboardType, provide, expectedContainedQueryVariables }) => {
beforeEach(() => { beforeEach(() => {
const mockResponse = jest const mockResponse = jest
.fn() .fn()
.mockResolvedValue(mockVulnerabilitySeveritiesGraphQLResponse({ dashboardType })); .mockResolvedValue(mockVulnerabilitySeveritiesGraphQLResponse({ dashboardType }));
const provide = { dashboardType, groupFullPath: undefined, projectFullPath: undefined };
if (expectedContainedQueryVariables.isGroup) {
provide.groupFullPath = fullPath;
} else if (expectedContainedQueryVariables.isProject) {
provide.projectFullPath = fullPath;
}
createWrapperWithApollo({ createWrapperWithApollo({
provide, provide: { dashboardType, ...provide },
propsData: { filters: { someFilter: 1 } }, propsData: { filters: { someFilter: 1 } },
query: mockResponse, query: mockResponse,
stubs: { VulnerabilityCountListLayout }, stubs: { VulnerabilityCountListLayout },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment