aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/src/utils/AccountIcon.spec.ts
blob: bbc7f031774bdbbb4d0ec536fee42154592facd7 (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
/*!
 * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
import { describe, expect, it, afterEach } from 'vitest'
import { generateAvatarSvg } from './AccountIcon'
describe('AccountIcon', () => {

	afterEach(() => {
		delete document.body.dataset.themes
	})

	it('should generate regular account avatar svg', () => {
		const svg = generateAvatarSvg('admin')
		expect(svg).toContain('/avatar/admin/32')
		expect(svg).not.toContain('dark')
		expect(svg).toContain('?guestFallback=true')
	})

	it('should generate guest account avatar svg', () => {
		const svg = generateAvatarSvg('admin', true)
		expect(svg).toContain('/avatar/guest/admin/32')
		expect(svg).not.toContain('dark')
		expect(svg).not.toContain('?guestFallback=true')
	})

	it('should generate dark mode account avatar svg', () => {
		document.body.dataset.themes = 'dark'
		const svg = generateAvatarSvg('admin')
		expect(svg).toContain('/avatar/admin/32/dark')
		expect(svg).toContain('?guestFallback=true')
	})

	it('should generate dark mode guest account avatar svg', () => {
		document.body.dataset.themes = 'dark'
		const svg = generateAvatarSvg('admin', true)
		expect(svg).toContain('/avatar/guest/admin/32/dark')
		expect(svg).not.toContain('?guestFallback=true')
	})
})