-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathTeamsListItem.spec.ts
More file actions
63 lines (53 loc) 路 2 KB
/
Copy pathTeamsListItem.spec.ts
File metadata and controls
63 lines (53 loc) 路 2 KB
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
59
60
61
62
63
/*!
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { ITeam } from '../types.ts'
import { shallowMount } from '@vue/test-utils'
import { describe, expect, it } from 'vitest'
import TeamMembers from './TeamMembers.vue'
import TeamResources from './TeamResources.vue'
import TeamsListItem from './TeamsListItem.vue'
/**
* Build a minimal team fixture. Override only the fields a given test cares about.
*
* @param overrides - partial team to merge over the defaults
*/
function makeTeam(overrides: Partial<ITeam> = {}): ITeam {
return {
id: 'team-1',
displayName: 'Marketing',
url: 'https://cloud.example/apps/contacts/circle/team-1',
members: [],
resources: [],
...overrides,
}
}
describe('TeamsListItem', () => {
// shallowMount stubs child components (TeamMembers, TeamResources, NcIconSvgWrapper),
// so these tests assert TeamsListItem's own behaviour without their internals.
it('renders the team name and links to the team URL', () => {
const team = makeTeam()
const wrapper = shallowMount(TeamsListItem, { props: { team } })
expect(wrapper.text()).toContain('Marketing')
expect(wrapper.get('a').attributes('href')).toBe(team.url)
})
it('hides members and resources when the team has none', () => {
const wrapper = shallowMount(TeamsListItem, { props: { team: makeTeam() } })
expect(wrapper.findComponent(TeamMembers).exists()).toBe(false)
expect(wrapper.findComponent(TeamResources).exists()).toBe(false)
})
it('renders members and resources when the team has them', () => {
const team = makeTeam({
members: [
{ singleId: 's1', displayName: 'Alice', type: 1, isUser: true, url: '#' },
],
resources: [
{ id: 'r1', name: 'Notes', fallbackIcon: '', iconUrl: '', url: '#' },
],
})
const wrapper = shallowMount(TeamsListItem, { props: { team } })
expect(wrapper.findComponent(TeamMembers).exists()).toBe(true)
expect(wrapper.findComponent(TeamResources).exists()).toBe(true)
})
})