2019-02-15 15:39:39 +05:30
|
|
|
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
|
|
|
import Vuex from 'vuex';
|
2020-10-24 23:57:45 +05:30
|
|
|
import { GlButton } from '@gitlab/ui';
|
2019-02-15 15:39:39 +05:30
|
|
|
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);
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
vm = shallowMount(NoChanges, {
|
2019-02-15 15:39:39 +05:30
|
|
|
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>',
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
expect(vm.find('script').exists()).toBe(false);
|
2019-02-15 15:39:39 +05:30
|
|
|
});
|
2020-07-28 23:09:34 +05:30
|
|
|
|
|
|
|
describe('Renders', () => {
|
|
|
|
it('Show create commit button', () => {
|
|
|
|
createComponent();
|
|
|
|
expect(vm.find(GlButton).exists()).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
2019-02-15 15:39:39 +05:30
|
|
|
});
|