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

newGroupConversationStore.spec.js « store « src - github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9005c588721f84760fd4055931e4019dc2a6e472 (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
import Vuex from 'vuex'
import { cloneDeep } from 'lodash'
import { createLocalVue } from '@vue/test-utils'

import newGroupConversationStore from './newGroupConversationStore.js'

describe('newGroupConversationStore', () => {
	let localVue = null
	let store = null

	beforeEach(() => {
		localVue = createLocalVue()
		localVue.use(Vuex)

		// eslint-disable-next-line import/no-named-as-default-member
		store = new Vuex.Store(cloneDeep(newGroupConversationStore))
	})

	afterEach(() => {
		jest.clearAllMocks()
	})

	test('toggles selected participants', () => {
		store.dispatch('updateSelectedParticipants', { id: 'participant-1' })
		store.dispatch('updateSelectedParticipants', { id: 'participant-2' })
		store.dispatch('updateSelectedParticipants', { id: 'participant-3' })

		expect(store.getters.selectedParticipants).toStrictEqual([
			{ id: 'participant-1' },
			{ id: 'participant-2' },
			{ id: 'participant-3' },
		])

		store.dispatch('updateSelectedParticipants', { id: 'participant-2' })

		expect(store.getters.selectedParticipants).toStrictEqual([
			{ id: 'participant-1' },
			{ id: 'participant-3' },
		])
	})

	test('purges selection', () => {
		expect(store.getters.selectedParticipants).toStrictEqual([])

		store.dispatch('updateSelectedParticipants', { id: 'participant-1' })
		store.dispatch('updateSelectedParticipants', { id: 'participant-2' })

		store.dispatch('purgeNewGroupConversationStore')

		expect(store.getters.selectedParticipants).toStrictEqual([])
	})

})