Welcome to mirror list, hosted at ThFree Co, Russian Federation.

AvatarWrapper.spec.js « AvatarWrapper « components « src - github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c072795ff9d9689dc07d26c7a49fbd6a1f678483 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { shallowMount } from '@vue/test-utils'
import AvatarWrapper from './AvatarWrapper'

describe('AvatarWrapper.vue', () => {
	it('Renders user avatars properly', () => {
		const wrapper = shallowMount(AvatarWrapper, {
			propsData: {
				id: 'test-id',
				source: 'users',
				name: 'test-name',
			},
		})
		expect(wrapper.vm.iconClass).toBe('')
		// Check that the first child is the avatar component
		expect(wrapper.element.firstChild.nodeName).toBe('AVATAR-STUB')
		expect(wrapper.props().size).toBe(32)
	})
	it('Renders group icons properly', () => {
		const wrapper = shallowMount(AvatarWrapper, {
			propsData: {
				id: '',
				source: 'groups',
				name: '',
			},
		})
		expect(wrapper.vm.iconClass).toBe('icon-contacts')
		// Check that the first child is a div
		expect(wrapper.element.firstChild.nodeName).toBe('DIV')
	})
	it('Renders email icons properly', () => {
		const wrapper = shallowMount(AvatarWrapper, {
			propsData: {
				id: '',
				source: 'emails',
				name: '',
			},
		})
		expect(wrapper.vm.iconClass).toBe('icon-mail')
		// Check that the first child is a div
		expect(wrapper.element.firstChild.nodeName).toBe('DIV')
		// proper size
		expect(wrapper.element.firstChild.classList).toContain('avatar-32px')
	})
	it('Renders guests icons properly', () => {
		const wrapper = shallowMount(AvatarWrapper, {
			propsData: {
				id: 'random-sha1',
				source: 'guests',
				name: '',
				size: 24,
			},
		})
		expect(wrapper.element.firstChild.classList).toContain('guest')
		expect(wrapper.element.firstChild.nodeName).toBe('DIV')
		// proper size
		expect(wrapper.element.firstChild.classList).toContain('avatar-24px')
	})
})