|
5 | 5 |
|
6 | 6 | import { shallowMount } from '@vue/test-utils' |
7 | 7 | import { describe, expect, it } from 'vitest' |
| 8 | +import NcAvatar from '@nextcloud/vue/components/NcAvatar' |
8 | 9 | import ContactMenuEntry from '../../../components/ContactsMenu/ContactMenuEntry.vue' |
9 | 10 |
|
10 | 11 | describe('Contact', function() { |
| 12 | + it('passes the avatar url to non-user contacts', () => { |
| 13 | + const view = shallowMount(ContactMenuEntry, { |
| 14 | + propsData: { |
| 15 | + contact: { |
| 16 | + id: '11111111-2222-3333-4444-555555555555', |
| 17 | + uid: '11111111-2222-3333-4444-555555555555', |
| 18 | + fullName: 'Jane Doe', |
| 19 | + avatar: 'https://localhost/remote.php/dav/addressbooks/users/admin/contacts/jane.vcf?photo', |
| 20 | + isUser: false, |
| 21 | + emailAddresses: [], |
| 22 | + actions: [], |
| 23 | + }, |
| 24 | + }, |
| 25 | + }) |
| 26 | + |
| 27 | + const avatar = view.findComponent(NcAvatar) |
| 28 | + expect(avatar.props('user')).toBeUndefined() |
| 29 | + expect(avatar.props('url')).toBe('https://localhost/remote.php/dav/addressbooks/users/admin/contacts/jane.vcf?photo') |
| 30 | + expect(avatar.props('displayName')).toBe('Jane Doe') |
| 31 | + }) |
| 32 | + |
| 33 | + it('lets user contacts resolve the avatar via their user id', () => { |
| 34 | + const view = shallowMount(ContactMenuEntry, { |
| 35 | + propsData: { |
| 36 | + contact: { |
| 37 | + id: 'jane', |
| 38 | + uid: 'jane', |
| 39 | + fullName: 'Jane Doe', |
| 40 | + avatar: 'https://localhost/remote.php/dav/addressbooks/system/system/system/jane.vcf?photo', |
| 41 | + isUser: true, |
| 42 | + emailAddresses: [], |
| 43 | + actions: [], |
| 44 | + }, |
| 45 | + }, |
| 46 | + }) |
| 47 | + |
| 48 | + const avatar = view.findComponent(NcAvatar) |
| 49 | + expect(avatar.props('user')).toBe('jane') |
| 50 | + expect(avatar.props('url')).toBeUndefined() |
| 51 | + }) |
| 52 | + |
11 | 53 | it('links to the top action', () => { |
12 | 54 | const view = shallowMount(ContactMenuEntry, { |
13 | 55 | propsData: { |
|
0 commit comments