eslint/excpect: should not be called conditionally

This commit fixes the error but not really the pattern. We should
consider refactoring the tests following these guidelines:
https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-conditional-expect.md
This commit is contained in:
Thomas Lavocat 2023-08-09 17:42:14 +02:00 committed by Lucas Garfield
parent a1834ed76e
commit 3b8afeaf7d
3 changed files with 40 additions and 32 deletions

View file

@ -1679,8 +1679,9 @@ describe('Click through all steps', () => {
.spyOn(api, 'composeImage')
.mockImplementation((body) => {
let id;
let excpectedBody = {};
if (body.image_requests[0].upload_request.type === 'aws') {
expect(body).toEqual({
excpectedBody = {
distribution: RHEL_8,
image_name: 'my-image-name',
image_description: 'this is a perfect description for image',
@ -1721,10 +1722,10 @@ describe('Click through all steps', () => {
'base-url': 'https://cdn.redhat.com/',
},
},
});
};
id = 'edbae1c2-62bc-42c1-ae0c-3110ab718f56';
} else if (body.image_requests[0].upload_request.type === 'gcp') {
expect(body).toEqual({
excpectedBody = {
distribution: RHEL_8,
image_name: 'my-image-name',
image_description: 'this is a perfect description for image',
@ -1765,10 +1766,10 @@ describe('Click through all steps', () => {
'base-url': 'https://cdn.redhat.com/',
},
},
});
};
id = 'edbae1c2-62bc-42c1-ae0c-3110ab718f57';
} else if (body.image_requests[0].upload_request.type === 'azure') {
expect(body).toEqual({
excpectedBody = {
distribution: RHEL_8,
image_name: 'my-image-name',
image_description: 'this is a perfect description for image',
@ -1811,10 +1812,10 @@ describe('Click through all steps', () => {
'base-url': 'https://cdn.redhat.com/',
},
},
});
};
id = 'edbae1c2-62bc-42c1-ae0c-3110ab718f58';
} else if (body.image_requests[0].image_type === 'vsphere-ova') {
expect(body).toEqual({
excpectedBody = {
distribution: RHEL_8,
image_name: 'my-image-name',
image_description: 'this is a perfect description for image',
@ -1853,10 +1854,10 @@ describe('Click through all steps', () => {
'base-url': 'https://cdn.redhat.com/',
},
},
});
};
id = 'edbae1c2-62bc-42c1-ae0c-3110ab718f59';
} else if (body.image_requests[0].image_type === 'guest-image') {
expect(body).toEqual({
excpectedBody = {
distribution: RHEL_8,
image_name: 'my-image-name',
image_description: 'this is a perfect description for image',
@ -1895,10 +1896,10 @@ describe('Click through all steps', () => {
'base-url': 'https://cdn.redhat.com/',
},
},
});
};
id = 'edbae1c2-62bc-42c1-ae0c-3110ab718f5a';
} else if (body.image_requests[0].image_type === 'image-installer') {
expect(body).toEqual({
excpectedBody = {
distribution: RHEL_8,
image_name: 'my-image-name',
image_description: 'this is a perfect description for image',
@ -1937,9 +1938,10 @@ describe('Click through all steps', () => {
'base-url': 'https://cdn.redhat.com/',
},
},
});
};
id = 'edbae1c2-62bc-42c1-ae0c-3110ab718f5b';
}
expect(body).toEqual(excpectedBody);
ids.unshift(id);
return Promise.resolve({ id });