Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 63 additions & 96 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"dependencies": {
"@linusborg/vue-simple-portal": "^0.1.5",
"@nextcloud/auth": "^2.0.0",
"@nextcloud/axios": "^2.3.0",
"@nextcloud/axios": "^2.4.0",
"@nextcloud/browser-storage": "^0.2.0",
"@nextcloud/capabilities": "^1.0.4",
"@nextcloud/dialogs": "^4.0.1",
Expand Down Expand Up @@ -80,7 +80,6 @@
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jest-localstorage-mock": "^2.4.26",
"jest-mock-axios": "^4.7.2",
"jest-mock-console": "^2.0.0",
"jest-transform-stub": "^2.0.0",
"regenerator-runtime": "^0.13.11",
Expand Down
4 changes: 0 additions & 4 deletions src/__mocks__/axios.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ import Conversation from './Conversation.vue'

import router from '../../../__mocks__/router.js'
import { CONVERSATION, PARTICIPANT, ATTENDEE } from '../../../constants.js'
import { leaveConversation } from '../../../services/participantsService.js'
import storeConfig from '../../../store/storeConfig.js'

jest.mock('@nextcloud/dialogs', () => ({
showSuccess: jest.fn(),
showError: jest.fn(),
}))

jest.mock('../../../services/participantsService', () => ({
leaveConversation: jest.fn(),
}))

// TODO fix after RouterLinkStub can support slots https://github.com/vuejs/vue-test-utils/issues/1803
const RouterLinkStub = true

Expand Down Expand Up @@ -357,11 +362,12 @@ describe('Conversation.vue', () => {
test('leaves conversation', async () => {
const actionHandler = jest.fn()
testStoreConfig.modules.participantsStore.actions.removeCurrentUserFromConversation = actionHandler

leaveConversation.mockResolvedValue()
const action = shallowMountAndGetAction('Leave conversation')
expect(action.exists()).toBe(true)

await action.find('button').trigger('click')
await flushPromises()

expect(actionHandler).toHaveBeenCalledWith(expect.anything(), { token: TOKEN })
})
Expand Down
10 changes: 7 additions & 3 deletions src/services/conversationsService.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import axios from '@nextcloud/axios'
import { loadState } from '@nextcloud/initial-state'
import { generateOcsUrl } from '@nextcloud/router'

import mockAxios from '../__mocks__/axios.js'
import { SHARE } from '../constants.js'
import { searchPossibleConversations } from './conversationsService.js'

jest.mock('@nextcloud/axios', () => ({
get: jest.fn(),
}))

jest.mock('@nextcloud/initial-state', () => ({
loadState: jest.fn(),
}))
Expand All @@ -27,7 +31,7 @@ describe('conversationsService', () => {

afterEach(() => {
// cleaning up the mess left behind the previous test
mockAxios.reset()
jest.clearAllMocks()
})

/**
Expand All @@ -46,7 +50,7 @@ describe('conversationsService', () => {
dummyOption: true,
}
)
expect(mockAxios.get).toHaveBeenCalledWith(
expect(axios.get).toHaveBeenCalledWith(
generateOcsUrl('core/autocomplete/get'),
{
dummyOption: true,
Expand Down
Loading