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

mr_widget_sha_mismatch_spec.js « states « components « vue_mr_widget « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2a343997cf58e9cc51dfb7f7936789b4f9447e11 (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
34
35
36
37
38
39
40
41
42
import { mount } from '@vue/test-utils';
import ShaMismatch from '~/vue_merge_request_widget/components/states/sha_mismatch.vue';
import { I18N_SHA_MISMATCH } from '~/vue_merge_request_widget/i18n';

function createComponent({ path = '' } = {}) {
  return mount(ShaMismatch, {
    propsData: {
      mr: {
        mergeRequestDiffsPath: path,
      },
    },
  });
}

describe('ShaMismatch', () => {
  let wrapper;
  const findActionButton = () => wrapper.find('[data-testid="action-button"]');

  beforeEach(() => {
    wrapper = createComponent();
  });

  afterEach(() => {
    wrapper.destroy();
  });

  it('should render warning message', () => {
    expect(wrapper.element.innerText).toContain(I18N_SHA_MISMATCH.warningMessage);
  });

  it('action button should have correct label', () => {
    expect(findActionButton().text()).toBe(I18N_SHA_MISMATCH.actionButtonLabel);
  });

  it('action button should link to the diff path', () => {
    const DIFF_PATH = '/gitlab-org/gitlab-test/-/merge_requests/6/diffs';

    wrapper = createComponent({ path: DIFF_PATH });

    expect(findActionButton().attributes('href')).toBe(DIFF_PATH);
  });
});