Commit 365ebd02 authored by Mark Florian's avatar Mark Florian

Merge branch 'vs-migrate-notes-to-jest' into 'master'

Migrate ee/notes to Jest

Closes #194297

See merge request gitlab-org/gitlab!27317
parents 0ae6cb7e 23eafed2
......@@ -3,7 +3,7 @@ import Vuex from 'vuex';
import DiffLineNoteForm from '~/diffs/components/diff_line_note_form.vue';
import NoteForm from '~/notes/components/note_form.vue';
import diffFileMockData from 'jest/diffs/mock_data/diff_file';
import note from '../../notes/mock_data';
import note from 'jest/notes/mock_data';
const localVue = createLocalVue();
localVue.use(Vuex);
......
......@@ -2,7 +2,7 @@ import { shallowMount } from '@vue/test-utils';
import { TEST_HOST } from 'spec/test_constants';
import createStore from '~/notes/stores';
import noteActions from '~/notes/components/note_actions.vue';
import { userDataMock } from '../../../../spec/frontend/notes/mock_data';
import { userDataMock } from 'jest/notes/mock_data';
describe('noteActions', () => {
let wrapper;
......@@ -48,7 +48,7 @@ describe('noteActions', () => {
const resolveButton = wrapper.find({ ref: 'resolveButton' });
expect(resolveButton.exists()).toBe(true);
expect(resolveButton.attributes('title')).toEqual('Thread stays unresolved');
expect(resolveButton.attributes('title')).toBe('Thread stays unresolved');
});
});
});
import Vue from 'vue';
import { createStore } from 'ee/batch_comments/stores';
import { keyboardDownEvent } from 'spec/issue_show/helpers';
import { noteableDataMock, discussionMock, notesDataMock } from 'spec/notes/mock_data';
import { keyboardDownEvent } from 'jest/issue_show/helpers';
import { noteableDataMock, discussionMock, notesDataMock } from 'jest/notes/mock_data';
import diffsModule from '~/diffs/store/modules';
import notesModule from '~/notes/stores/modules';
import issueNoteForm from '~/notes/components/note_form.vue';
......@@ -45,7 +45,7 @@ describe('issue_note_form component', () => {
describe('on enter', () => {
it('should add comment when cmd+enter is pressed', () => {
spyOn(vm, 'handleUpdate').and.callThrough();
jest.spyOn(vm, 'handleUpdate');
vm.$el.querySelector('textarea').value = 'Foo';
vm.$el.querySelector('textarea').dispatchEvent(keyboardDownEvent(13, true));
......@@ -53,7 +53,7 @@ describe('issue_note_form component', () => {
});
it('should add comment when ctrl+enter is pressed', () => {
spyOn(vm, 'handleUpdate').and.callThrough();
jest.spyOn(vm, 'handleUpdate');
vm.$el.querySelector('textarea').value = 'Foo';
vm.$el.querySelector('textarea').dispatchEvent(keyboardDownEvent(13, false, true));
......@@ -63,12 +63,8 @@ describe('issue_note_form component', () => {
});
describe('with batch comments', () => {
beforeEach(done => {
store
.dispatch('batchComments/enableBatchComments')
.then(vm.$nextTick)
.then(done)
.catch(done.fail);
beforeEach(() => {
return store.dispatch('batchComments/enableBatchComments').then(vm.$nextTick);
});
it('shows resolve checkbox', () => {
......@@ -77,21 +73,19 @@ describe('issue_note_form component', () => {
).not.toBe(null);
});
it('hides actions for commits', done => {
it('hides actions for commits', () => {
vm.discussion.for_commit = true;
vm.$nextTick(() => {
return vm.$nextTick(() => {
expect(vm.$el.querySelector('.note-form-actions').textContent).not.toContain(
'Start a review',
);
done();
});
});
describe('on enter', () => {
it('should start review or add to review when cmd+enter is pressed', () => {
spyOn(vm, 'handleAddToReview').and.callThrough();
jest.spyOn(vm, 'handleAddToReview');
vm.$el.querySelector('textarea').value = 'Foo';
vm.$el.querySelector('textarea').dispatchEvent(keyboardDownEvent(13, true));
......@@ -99,7 +93,7 @@ describe('issue_note_form component', () => {
});
it('should start review or add to review when ctrl+enter is pressed', () => {
spyOn(vm, 'handleAddToReview').and.callThrough();
jest.spyOn(vm, 'handleAddToReview');
vm.$el.querySelector('textarea').value = 'Foo';
vm.$el.querySelector('textarea').dispatchEvent(keyboardDownEvent(13, false, true));
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment