/
githubmirror
/
client
Обзор
Документация
Войти
/
githubmirror
/
client
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
shared/stores/tests/team-building.test.ts
82 строки
3 KB
chrisnojima
fix(chat): new-chat stale selection + blank thread header entering created conversations (#29452)
21 июл 2026, 21:24
Не верифицирован
21 июл 2026, 21:24
bc6e852
Код
Авторство
О чём код?
/// <reference types="jest" /> import type * as T from '@/constants/types' import {resetAllStores} from '@/util/zustand' import {createTBStore} from '../team-building' afterEach(() => { resetAllStores() }) const makeUser = (id: string): T.TB.User => ({ id, prettyName: id, serviceId: 'keybase', serviceMap: {keybase: id}, username: id, }) as T.TB.User test('users can be added and removed from teamSoFar', () => { const store = createTBStore('teams') const alice = makeUser('alice') const bob = makeUser('bob') store.getState().dispatch.addUsersToTeamSoFar([alice, alice, bob]) expect(store.getState().teamSoFar.size).toBe(2) expect(store.getState().teamSoFar.has(alice)).toBe(true) store.getState().dispatch.removeUsersFromTeamSoFar(['alice']) expect(store.getState().teamSoFar.size).toBe(1) expect(store.getState().teamSoFar.has(alice)).toBe(false) expect(store.getState().teamSoFar.has(bob)).toBe(true) }) test('local setters update role, notifications, and error state', () => { const store = createTBStore('chat') store.getState().dispatch.selectRole('admin') store.getState().dispatch.changeSendNotification(false) store.getState().dispatch.setError('boom') expect(store.getState().selectedRole).toBe('admin') expect(store.getState().sendNotification).toBe(false) expect(store.getState().error).toBe('boom') }) test('finishedTeamBuilding clears the selection outside the teams namespace', () => { const store = createTBStore('chat') const alice = makeUser('alice') store.getState().dispatch.addUsersToTeamSoFar([alice]) store.getState().dispatch.setError('boom') store.getState().dispatch.finishedTeamBuilding() expect(store.getState().namespace).toBe('chat') expect(store.getState().teamSoFar.size).toBe(0) expect(store.getState().error).toBe('') }) test('finishedTeamBuilding clears transient state but preserves namespace and selections', () => { const store = createTBStore('teams') const alice = makeUser('alice') store.getState().dispatch.addUsersToTeamSoFar([alice]) store.getState().dispatch.selectRole('admin') store.getState().dispatch.changeSendNotification(false) store.getState().dispatch.setError('boom') store.getState().dispatch.finishedTeamBuilding() expect(store.getState().namespace).toBe('teams') expect(store.getState().selectedRole).toBe('admin') expect(store.getState().sendNotification).toBe(false) expect(store.getState().teamSoFar.size).toBe(1) expect(store.getState().error).toBe('') expect(store.getState().searchResults.size).toBe(0) expect(store.getState()).not.toHaveProperty('searchLimit') expect(store.getState()).not.toHaveProperty('searchQuery') expect(store.getState()).not.toHaveProperty('selectedService') })