Merge branch 'feat/inda-383-daily-stat' into 'main'
[ProtonMail-WebClient.git] / packages / pass / store / optimistic / utils / split-history.spec.ts
blobb426b421be8383ecdf9f5f4fcb2be517e8885059
1 import type { WithOptimisticHistory } from '../types';
2 import { isOptimisticHistoryItem } from './assertions';
3 import { splitHistoryOnFirstOptimisticItem } from './split-history';
4 import { createTestDeterministicAction, createTestOptimisticHistoryItem } from './testing.utils';
6 describe('splitHistoryOnFirstOptimisticItem', () => {
7     test('should return empty right side if no optimistic actions in history', () => {
8         const history = [createTestDeterministicAction()];
9         const [left, right] = splitHistoryOnFirstOptimisticItem(history);
11         expect(right.length).toEqual(0);
12         expect(left).toEqual(history);
13     });
15     test('left side should only contain redux actions and no optimistic actions', () => {
16         const history: WithOptimisticHistory = [
17             createTestDeterministicAction(),
18             createTestOptimisticHistoryItem(),
19             createTestDeterministicAction(),
20             createTestOptimisticHistoryItem(),
21         ];
23         const [left, right] = splitHistoryOnFirstOptimisticItem(history);
25         expect(left.some(isOptimisticHistoryItem)).toBe(false);
26         expect(left).toEqual(history.slice(0, 1));
27         expect(right).toEqual(history.slice(1));
28     });
29 });