diff options
Diffstat (limited to 'core/src/tests/views/ContactsMenu.spec.js')
-rw-r--r-- | core/src/tests/views/ContactsMenu.spec.js | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/core/src/tests/views/ContactsMenu.spec.js b/core/src/tests/views/ContactsMenu.spec.js index c28d7226e79..084c3215e47 100644 --- a/core/src/tests/views/ContactsMenu.spec.js +++ b/core/src/tests/views/ContactsMenu.spec.js @@ -3,13 +3,18 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -import axios from '@nextcloud/axios' import { mount, shallowMount } from '@vue/test-utils' +import { describe, expect, it, vi } from 'vitest' import ContactsMenu from '../../views/ContactsMenu.vue' -jest.mock('@nextcloud/axios', () => ({ - post: jest.fn(), +const axios = vi.hoisted(() => ({ + post: vi.fn(), +})) +vi.mock('@nextcloud/axios', () => ({ default: axios })) + +vi.mock('@nextcloud/auth', () => ({ + getCurrentUser: () => ({ uid: 'user', isAdmin: false, displayName: 'User' }), })) describe('ContactsMenu', function() { @@ -39,7 +44,7 @@ describe('ContactsMenu', function() { it('shows error view when contacts can not be loaded', async () => { const view = mount(ContactsMenu) axios.post.mockResolvedValue({}) - jest.spyOn(console, 'error').mockImplementation(() => {}) + vi.spyOn(console, 'error').mockImplementation(() => {}) try { await view.vm.handleOpen() @@ -56,7 +61,7 @@ describe('ContactsMenu', function() { it('shows text when there are no contacts', async () => { const view = mount(ContactsMenu) - axios.post.mockResolvedValue({ + axios.post.mockResolvedValueOnce({ data: { contacts: [], contactsAppEnabled: false, @@ -82,19 +87,19 @@ describe('ContactsMenu', function() { topAction: { title: 'Mail', icon: 'icon-mail', - hyperlink: 'mailto:deboraoliver%40centrexin.com' + hyperlink: 'mailto:deboraoliver%40centrexin.com', }, actions: [ { title: 'Mail', icon: 'icon-mail', - hyperlink: 'mailto:mathisholland%40virxo.com' + hyperlink: 'mailto:mathisholland%40virxo.com', }, { title: 'Details', icon: 'icon-info', - hyperlink: 'https://localhost/index.php/apps/contacts' - } + hyperlink: 'https://localhost/index.php/apps/contacts', + }, ], lastMessage: '', emailAddresses: [], @@ -105,23 +110,23 @@ describe('ContactsMenu', function() { topAction: { title: 'Mail', icon: 'icon-mail', - hyperlink: 'mailto:ceciliasoto%40essensia.com' + hyperlink: 'mailto:ceciliasoto%40essensia.com', }, actions: [ { title: 'Mail', icon: 'icon-mail', - hyperlink: 'mailto:pearliesellers%40inventure.com' + hyperlink: 'mailto:pearliesellers%40inventure.com', }, { title: 'Details', icon: 'icon-info', - hyperlink: 'https://localhost/index.php/apps/contacts' - } + hyperlink: 'https://localhost/index.php/apps/contacts', + }, ], lastMessage: 'cu', emailAddresses: [], - } + }, ], contactsAppEnabled: true, }, |