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

no_changes_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: 2795c68b4eef0c4d1f68fc0853512f5c5b85c298 (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
43
44
45
46
47
48
import { createLocalVue, shallowMount } from '@vue/test-utils';
import Vuex from 'vuex';
import { GlButton } from '@gitlab/ui';
import { createStore } from '~/mr_notes/stores';
import NoChanges from '~/diffs/components/no_changes.vue';

describe('Diff no changes empty state', () => {
  let vm;

  function createComponent(extendStore = () => {}) {
    const localVue = createLocalVue();
    localVue.use(Vuex);

    const store = createStore();
    extendStore(store);

    vm = shallowMount(NoChanges, {
      localVue,
      store,
      propsData: {
        changesEmptyStateIllustration: '',
      },
    });
  }

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

  it('prevents XSS', () => {
    createComponent(store => {
      // eslint-disable-next-line no-param-reassign
      store.state.notes.noteableData = {
        source_branch: '<script>alert("test");</script>',
        target_branch: '<script>alert("test");</script>',
      };
    });

    expect(vm.contains('script')).toBe(false);
  });

  describe('Renders', () => {
    it('Show create commit button', () => {
      createComponent();
      expect(vm.find(GlButton).exists()).toBe(true);
    });
  });
});