debian-mirror-gitlab/spec/frontend/diffs/components/diff_code_quality_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
1.5 KiB
JavaScript
Raw Normal View History

2022-08-13 15:12:31 +05:30
import { mountExtended, shallowMountExtended } from 'helpers/vue_test_utils_helper';
import DiffCodeQuality from '~/diffs/components/diff_code_quality.vue';
2023-06-20 00:43:36 +05:30
import DiffCodeQualityItem from '~/diffs/components/diff_code_quality_item.vue';
2023-03-04 22:38:38 +05:30
import { NEW_CODE_QUALITY_FINDINGS } from '~/diffs/i18n';
2022-08-13 15:12:31 +05:30
import { multipleFindingsArr } from '../mock_data/diff_code_quality';
let wrapper;
2023-06-20 00:43:36 +05:30
const diffItems = () => wrapper.findAllComponents(DiffCodeQualityItem);
2023-03-04 22:38:38 +05:30
const findHeading = () => wrapper.findByTestId(`diff-codequality-findings-heading`);
2022-08-13 15:12:31 +05:30
describe('DiffCodeQuality', () => {
const createWrapper = (codeQuality, mountFunction = mountExtended) => {
return mountFunction(DiffCodeQuality, {
propsData: {
expandedLines: [],
codeQuality,
},
});
};
it('hides details and throws hideCodeQualityFindings event on close click', async () => {
wrapper = createWrapper(multipleFindingsArr);
expect(wrapper.findByTestId('diff-codequality').exists()).toBe(true);
await wrapper.findByTestId('diff-codequality-close').trigger('click');
expect(wrapper.emitted('hideCodeQualityFindings').length).toBe(1);
});
2023-06-20 00:43:36 +05:30
it('renders heading and correct amount of list items for codequality array and their description', () => {
wrapper = createWrapper(multipleFindingsArr, shallowMountExtended);
2022-08-13 15:12:31 +05:30
2023-06-20 00:43:36 +05:30
expect(findHeading().text()).toEqual(NEW_CODE_QUALITY_FINDINGS);
2022-08-13 15:12:31 +05:30
2023-06-20 00:43:36 +05:30
expect(diffItems()).toHaveLength(multipleFindingsArr.length);
expect(diffItems().at(0).props().finding).toEqual(multipleFindingsArr[0]);
2022-08-13 15:12:31 +05:30
});
});