Refactor props tests

Refactor how props are tested to account for the fact that DAST Saved
Scans list component now exposes errorMessage and errorDetails as props,
while other listings expose them as attributes.
parent 8b8d9cb5
......@@ -171,6 +171,31 @@ describe('EE - DastProfiles', () => {
});
});
it.each`
profileType | key | givenData | expectedValue | exposedAsProp
${'dastProfiles'} | ${'errorMessage'} | ${{ errorMessage: 'foo' }} | ${'foo'} | ${true}
${'dastProfiles'} | ${'errorDetails'} | ${{ errorDetails: ['foo'] }} | ${['foo']} | ${true}
${'dastProfiles'} | ${'has-more-profiles-to-load'} | ${{ pageInfo: { hasNextPage: true } }} | ${'true'} | ${false}
${'siteProfiles'} | ${'error-message'} | ${{ errorMessage: 'foo' }} | ${'foo'} | ${false}
${'siteProfiles'} | ${'error-details'} | ${{ errorDetails: ['foo'] }} | ${'foo'} | ${false}
${'siteProfiles'} | ${'has-more-profiles-to-load'} | ${{ pageInfo: { hasNextPage: true } }} | ${'true'} | ${false}
${'scannerProfiles'} | ${'error-message'} | ${{ errorMessage: 'foo' }} | ${'foo'} | ${false}
${'scannerProfiles'} | ${'error-details'} | ${{ errorDetails: ['foo'] }} | ${'foo'} | ${false}
${'scannerProfiles'} | ${'has-more-profiles-to-load'} | ${{ pageInfo: { hasNextPage: true } }} | ${'true'} | ${false}
`(
'passes down $key properly for $profileType',
async ({ profileType, key, givenData, expectedValue, exposedAsProp }) => {
const propGetter = exposedAsProp ? 'props' : 'attributes';
createComponent();
wrapper.setData({
profileTypes: { [profileType]: givenData },
});
await wrapper.vm.$nextTick();
expect(getProfilesComponent(profileType)[propGetter](key)).toEqual(expectedValue);
},
);
describe.each`
description | profileType
${'Saved Scans List'} | ${'dastProfiles'}
......@@ -187,19 +212,6 @@ describe('EE - DastProfiles', () => {
expect(getProfilesComponent(profileType).attributes('is-loading')).toBe('true');
});
it.each`
givenData | propName | expectedPropValue
${{ profileTypes: { [profileType]: { errorMessage: 'foo' } } }} | ${'error-message'} | ${'foo'}
${{ profileTypes: { [profileType]: { errorDetails: ['foo'] } } }} | ${'error-details'} | ${'foo'}
${{ profileTypes: { [profileType]: { pageInfo: { hasNextPage: true } } } }} | ${'has-more-profiles-to-load'} | ${'true'}
`('passes down $propName correctly', async ({ givenData, propName, expectedPropValue }) => {
wrapper.setData(givenData);
await wrapper.vm.$nextTick();
expect(getProfilesComponent(profileType).attributes(propName)).toEqual(expectedPropValue);
});
it('fetches more results when "@load-more-profiles" is emitted', () => {
const {
$apollo: {
......
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