Commit dd7a34c8 authored by Mike Greiling's avatar Mike Greiling

Merge branch '214450-follow-up-use-note-header-component-in-event-item-component' into 'master'

Use shallowMount and .toHaveLength() for tests

See merge request gitlab-org/gitlab!29670
parents a27cdcf2 61be1245
...@@ -48,7 +48,7 @@ describe('Event Item', () => { ...@@ -48,7 +48,7 @@ describe('Event Item', () => {
expect(wrapper.props().iconClass).toBe('ci-status-icon-success'); expect(wrapper.props().iconClass).toBe('ci-status-icon-success');
}); });
it('renders the action buttons tontainer', () => { it('renders the action buttons container', () => {
expect(wrapper.find('.action-buttons')).toExist(); expect(wrapper.find('.action-buttons')).toExist();
}); });
}); });
......
...@@ -110,7 +110,7 @@ describe('History Comment', () => { ...@@ -110,7 +110,7 @@ describe('History Comment', () => {
return axios.waitForAll(); return axios.waitForAll();
}) })
.then(() => { .then(() => {
expect(mockAxios.history.post.length).toBe(1); expect(mockAxios.history.post).toHaveLength(1);
expect(wrapper.emitted().onCommentAdded).toBeTruthy(); expect(wrapper.emitted().onCommentAdded).toBeTruthy();
expect(wrapper.emitted().onCommentAdded[0][0]).toEqual(comment); expect(wrapper.emitted().onCommentAdded[0][0]).toEqual(comment);
}); });
...@@ -125,7 +125,7 @@ describe('History Comment', () => { ...@@ -125,7 +125,7 @@ describe('History Comment', () => {
return axios.waitForAll(); return axios.waitForAll();
}) })
.then(() => { .then(() => {
expect(mockAxios.history.post.length).toBe(1); expect(mockAxios.history.post).toHaveLength(1);
expect(createFlash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
expect(commentEditor().exists()).toBe(true); expect(commentEditor().exists()).toBe(true);
}); });
...@@ -198,7 +198,7 @@ describe('History Comment', () => { ...@@ -198,7 +198,7 @@ describe('History Comment', () => {
return axios.waitForAll(); return axios.waitForAll();
}) })
.then(() => { .then(() => {
expect(mockAxios.history.delete.length).toBe(1); expect(mockAxios.history.delete).toHaveLength(1);
expect(wrapper.emitted().onCommentDeleted).toBeTruthy(); expect(wrapper.emitted().onCommentDeleted).toBeTruthy();
expect(wrapper.emitted().onCommentDeleted[0][0]).toEqual(comment); expect(wrapper.emitted().onCommentDeleted[0][0]).toEqual(comment);
}); });
...@@ -215,7 +215,7 @@ describe('History Comment', () => { ...@@ -215,7 +215,7 @@ describe('History Comment', () => {
return axios.waitForAll(); return axios.waitForAll();
}) })
.then(() => { .then(() => {
expect(mockAxios.history.delete.length).toBe(1); expect(mockAxios.history.delete).toHaveLength(1);
expect(createFlash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
}); });
}); });
...@@ -234,7 +234,7 @@ describe('History Comment', () => { ...@@ -234,7 +234,7 @@ describe('History Comment', () => {
return axios.waitForAll(); return axios.waitForAll();
}) })
.then(() => { .then(() => {
expect(mockAxios.history.put.length).toBe(1); expect(mockAxios.history.put).toHaveLength(1);
expect(wrapper.emitted().onCommentUpdated).toBeTruthy(); expect(wrapper.emitted().onCommentUpdated).toBeTruthy();
expect(wrapper.emitted().onCommentUpdated[0][0]).toEqual(responseData); expect(wrapper.emitted().onCommentUpdated[0][0]).toEqual(responseData);
expect(wrapper.emitted().onCommentUpdated[0][1]).toEqual(comment); expect(wrapper.emitted().onCommentUpdated[0][1]).toEqual(comment);
...@@ -250,7 +250,7 @@ describe('History Comment', () => { ...@@ -250,7 +250,7 @@ describe('History Comment', () => {
return axios.waitForAll(); return axios.waitForAll();
}) })
.then(() => { .then(() => {
expect(mockAxios.history.put.length).toBe(1); expect(mockAxios.history.put).toHaveLength(1);
expect(createFlash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
}); });
}); });
......
import { mount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import HistoryEntry from 'ee/vulnerabilities/components/history_entry.vue'; import HistoryEntry from 'ee/vulnerabilities/components/history_entry.vue';
import EventItem from 'ee/vue_shared/security_reports/components/event_item.vue'; import EventItem from 'ee/vue_shared/security_reports/components/event_item.vue';
...@@ -30,10 +30,9 @@ describe('History Entry', () => { ...@@ -30,10 +30,9 @@ describe('History Entry', () => {
const createWrapper = (...notes) => { const createWrapper = (...notes) => {
const discussion = { notes }; const discussion = { notes };
wrapper = mount(HistoryEntry, { wrapper = shallowMount(HistoryEntry, {
propsData: { propsData: { discussion },
discussion, stubs: { EventItem },
},
}); });
}; };
...@@ -66,7 +65,7 @@ describe('History Entry', () => { ...@@ -66,7 +65,7 @@ describe('History Entry', () => {
createWrapper(systemNote); createWrapper(systemNote);
expect(newComment().exists()).toBe(true); expect(newComment().exists()).toBe(true);
expect(existingComments().length).toBe(0); expect(existingComments()).toHaveLength(0);
}); });
it('displays comments when there are comments', () => { it('displays comments when there are comments', () => {
...@@ -74,7 +73,7 @@ describe('History Entry', () => { ...@@ -74,7 +73,7 @@ describe('History Entry', () => {
createWrapper(systemNote, commentNote, commentNoteClone); createWrapper(systemNote, commentNote, commentNoteClone);
expect(newComment().exists()).toBe(false); expect(newComment().exists()).toBe(false);
expect(existingComments().length).toBe(2); expect(existingComments()).toHaveLength(2);
expect(commentAt(0).props('comment')).toEqual(commentNote); expect(commentAt(0).props('comment')).toEqual(commentNote);
expect(commentAt(1).props('comment')).toEqual(commentNoteClone); expect(commentAt(1).props('comment')).toEqual(commentNoteClone);
}); });
...@@ -85,7 +84,7 @@ describe('History Entry', () => { ...@@ -85,7 +84,7 @@ describe('History Entry', () => {
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(newComment().exists()).toBe(false); expect(newComment().exists()).toBe(false);
expect(existingComments().length).toBe(1); expect(existingComments()).toHaveLength(1);
expect(commentAt(0).props('comment')).toEqual(commentNote); expect(commentAt(0).props('comment')).toEqual(commentNote);
}); });
}); });
...@@ -106,7 +105,7 @@ describe('History Entry', () => { ...@@ -106,7 +105,7 @@ describe('History Entry', () => {
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(newComment().exists()).toBe(true); expect(newComment().exists()).toBe(true);
expect(existingComments().length).toBe(0); expect(existingComments()).toHaveLength(0);
}); });
}); });
}); });
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