Welcome to mirror list, hosted at ThFree Co, Russian Federation.

diff_inline_findings_spec.js « components « diffs « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 65b2abe7dd547d71d138f9a7b34138eaca910d92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import DiffInlineFindings from '~/diffs/components/diff_inline_findings.vue';
import DiffInlineFindingsItem from '~/diffs/components/diff_inline_findings_item.vue';
import { NEW_CODE_QUALITY_FINDINGS } from '~/diffs/i18n';
import { multipleCodeQualityNoSast } from '../mock_data/inline_findings';

let wrapper;
const heading = () => wrapper.findByTestId('diff-inline-findings-heading');
const diffInlineFindingsItems = () => wrapper.findAllComponents(DiffInlineFindingsItem);

describe('DiffInlineFindings', () => {
  const createWrapper = () => {
    return shallowMountExtended(DiffInlineFindings, {
      propsData: {
        title: NEW_CODE_QUALITY_FINDINGS,
        findings: multipleCodeQualityNoSast.codeQuality,
      },
    });
  };

  it('renders the title correctly', () => {
    wrapper = createWrapper();
    expect(heading().text()).toBe(NEW_CODE_QUALITY_FINDINGS);
  });

  it('renders the correct number of DiffInlineFindingsItem components with correct props', () => {
    wrapper = createWrapper();
    expect(diffInlineFindingsItems()).toHaveLength(multipleCodeQualityNoSast.codeQuality.length);
    expect(diffInlineFindingsItems().wrappers[0].props('finding')).toEqual(
      wrapper.props('findings')[0],
    );
  });
});