forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLiveActivityFeed.test.tsx
More file actions
55 lines (49 loc) · 2.04 KB
/
Copy pathLiveActivityFeed.test.tsx
File metadata and controls
55 lines (49 loc) · 2.04 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
import { render, screen } from '@testing-library/react';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { LiveActivityFeed } from './LiveActivityFeed';
import * as useCollaborationModule from '../../hooks/useCollaboration';
vi.mock('../../hooks/useCollaboration');
describe('LiveActivityFeed', () => {
beforeEach(() => {
vi.clearAllMocks();
});
it('renders empty state when no activities', () => {
vi.mocked(useCollaborationModule.useCollaboration).mockReturnValue({
connected: true,
presence: {},
activities: [],
conflicts: [],
joinSplit: vi.fn(),
leaveSplit: vi.fn(),
setTyping: vi.fn(),
sendUpdate: vi.fn(),
resolveConflict: vi.fn(),
updateCursor: vi.fn(),
});
render(<LiveActivityFeed />);
expect(screen.getByText('No recent activity')).toBeDefined();
});
it('renders activity list when populated', () => {
vi.mocked(useCollaborationModule.useCollaboration).mockReturnValue({
connected: true,
presence: {},
activities: [
{ id: '1', type: 'payment-status', userId: 'u1', userName: 'Alice', message: 'paid their share', timestamp: new Date(), splitId: 's1' },
{ id: '2', type: 'item-added', userId: 'u2', userName: 'Bob', message: 'added a new item', timestamp: new Date(), splitId: 's1' }
],
conflicts: [],
joinSplit: vi.fn(),
leaveSplit: vi.fn(),
setTyping: vi.fn(),
sendUpdate: vi.fn(),
resolveConflict: vi.fn(),
updateCursor: vi.fn(),
});
render(<LiveActivityFeed />);
expect(screen.getByText('Live Feed')).toBeDefined();
expect(screen.getByText('Alice')).toBeDefined();
expect(screen.getByText('paid their share')).toBeDefined();
expect(screen.getByText('Bob')).toBeDefined();
expect(screen.getByText('added a new item')).toBeDefined();
});
});