diff --git a/src/components/LeftSidebar/ConversationsList/Conversation.spec.js b/src/components/LeftSidebar/ConversationsList/Conversation.spec.js index 5a6ab3ad4fd..1222bd90fb5 100644 --- a/src/components/LeftSidebar/ConversationsList/Conversation.spec.js +++ b/src/components/LeftSidebar/ConversationsList/Conversation.spec.js @@ -1,14 +1,17 @@ import { createLocalVue, shallowMount, mount } from '@vue/test-utils' import flushPromises from 'flush-promises' // TODO fix after migration to @vue/test-utils v2.0.0 import { cloneDeep } from 'lodash' +import VueRouter from 'vue-router' import Vuex from 'vuex' import { showSuccess, showError } from '@nextcloud/dialogs' import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js' +import NcListItem from '@nextcloud/vue/dist/Components/NcListItem.js' import Conversation from './Conversation.vue' +import router from '../../../__mocks__/router.js' import { CONVERSATION, PARTICIPANT, ATTENDEE } from '../../../constants.js' import storeConfig from '../../../store/storeConfig.js' @@ -274,7 +277,36 @@ describe('Conversation.vue', () => { }) }) - describe('actions', () => { + describe('actions (real router)', () => { + beforeEach(() => { + localVue.use(VueRouter) + }) + + test('change route on click event', async () => { + const wrapper = mount(Conversation, { + localVue, + router, + store, + stubs: { + NcListItem, + }, + propsData: { + isSearchResult: false, + item, + }, + }) + + const el = wrapper.findComponent({ name: 'NcListItem' }) + expect(el.exists()).toBe(true) + + await el.find('a').trigger('click') + + expect(wrapper.vm.$route.name).toBe('conversation') + expect(wrapper.vm.$route.params).toStrictEqual({ token: TOKEN }) + }) + }) + + describe('actions (mock router)', () => { let $router beforeEach(() => { @@ -321,27 +353,6 @@ describe('Conversation.vue', () => { return findNcActionButton(el, actionName) } - test('forwards click event on list item', async () => { - const wrapper = mount(Conversation, { - localVue, - store, - stubs: { - RouterLink: RouterLinkStub, - }, - propsData: { - isSearchResult: false, - item, - }, - }) - - const el = wrapper.findComponent({ name: 'NcListItem' }) - expect(el.exists()).toBe(true) - - await el.find('a').trigger('click') - - expect(wrapper.emitted().click).toBeTruthy() - }) - describe('leaving conversation', () => { test('leaves conversation', async () => { const actionHandler = jest.fn() diff --git a/src/components/LeftSidebar/ConversationsList/Conversation.vue b/src/components/LeftSidebar/ConversationsList/Conversation.vue index 791d05eeafc..b4d72b99198 100644 --- a/src/components/LeftSidebar/ConversationsList/Conversation.vue +++ b/src/components/LeftSidebar/ConversationsList/Conversation.vue @@ -101,7 +101,7 @@