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

fork_suggestion_spec.js « components « repository « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a9e5c18c0a9b42711e5e1ff71e6f836c1eaa7af6 (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 { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import ForkSuggestion from '~/repository/components/fork_suggestion.vue';

const DEFAULT_PROPS = { forkPath: 'some_file.js/fork' };

describe('ForkSuggestion component', () => {
  let wrapper;

  const createComponent = () => {
    wrapper = shallowMountExtended(ForkSuggestion, {
      propsData: { ...DEFAULT_PROPS },
    });
  };

  beforeEach(() => createComponent());

  const { i18n } = ForkSuggestion;
  const findMessage = () => wrapper.findByTestId('message');
  const findForkButton = () => wrapper.findByTestId('fork');
  const findCancelButton = () => wrapper.findByTestId('cancel');

  it('renders a message', () => {
    expect(findMessage().text()).toBe(i18n.message);
  });

  it('renders a Fork button', () => {
    const forkButton = findForkButton();

    expect(forkButton.text()).toBe(i18n.fork);
    expect(forkButton.attributes('href')).toBe(DEFAULT_PROPS.forkPath);
  });

  it('renders a Cancel button', () => {
    expect(findCancelButton().text()).toBe(i18n.cancel);
  });

  it('emits a cancel event when Cancel button is clicked', () => {
    findCancelButton().vm.$emit('click');

    expect(wrapper.emitted('cancel')).toEqual([[]]);
  });
});