debian-mirror-gitlab/spec/frontend/security_configuration/configuration_table_spec.js

53 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-03-11 19:13:27 +05:30
import { mount } from '@vue/test-utils';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import ConfigurationTable from '~/security_configuration/components/configuration_table.vue';
2021-06-08 01:23:25 +05:30
import { scanners, UPGRADE_CTA } from '~/security_configuration/components/constants';
2021-03-11 19:13:27 +05:30
import {
REPORT_TYPE_SAST,
2021-04-17 20:07:23 +05:30
REPORT_TYPE_SECRET_DETECTION,
2021-03-11 19:13:27 +05:30
} from '~/vue_shared/security_reports/constants';
describe('Configuration Table Component', () => {
let wrapper;
const createComponent = () => {
2021-06-08 01:23:25 +05:30
wrapper = extendedWrapper(
mount(ConfigurationTable, {
provide: {
projectPath: 'testProjectPath',
},
}),
);
2021-03-11 19:13:27 +05:30
};
2021-04-17 20:07:23 +05:30
const findHelpLinks = () => wrapper.findAll('[data-testid="help-link"]');
2021-03-11 19:13:27 +05:30
afterEach(() => {
wrapper.destroy();
});
beforeEach(() => {
createComponent();
});
2021-04-17 20:07:23 +05:30
describe.each(scanners.map((scanner, i) => [scanner, i]))('given scanner %s', (scanner, i) => {
it('should match strings', () => {
expect(wrapper.text()).toContain(scanner.name);
expect(wrapper.text()).toContain(scanner.description);
if (scanner.type === REPORT_TYPE_SAST) {
2021-06-08 01:23:25 +05:30
expect(wrapper.findByTestId(scanner.type).text()).toBe('Configure via Merge Request');
} else if (scanner.type === REPORT_TYPE_SECRET_DETECTION) {
expect(wrapper.findByTestId(scanner.type).exists()).toBe(false);
} else {
2021-04-17 20:07:23 +05:30
expect(wrapper.findByTestId(scanner.type).text()).toMatchInterpolatedText(UPGRADE_CTA);
}
});
it('should show expected help link', () => {
const helpLink = findHelpLinks().at(i);
expect(helpLink.attributes('href')).toBe(scanner.helpPath);
});
2021-03-11 19:13:27 +05:30
});
});