Merge branch 'feat/inda-383-daily-stat' into 'main'
[ProtonMail-WebClient.git] / packages / docs-core / lib / Models / DecryptedCommit.spec.ts
blobdbd17407c41937b32be47d3e02642c27075f0843
1 import { DecryptedMessage } from '@proton/docs-shared'
2 import { DecryptedCommit } from './DecryptedCommit'
4 describe('DecryptedCommit', () => {
5   it('should create an instance', () => {
6     const decryptedCommit = new DecryptedCommit('commitId', [
7       new DecryptedMessage({
8         content: new Uint8Array([1, 2, 3]),
9         signature: new Uint8Array([4, 5, 6]),
10         authorAddress: 'authorAddress',
11         aad: 'aad',
12         timestamp: 123456,
13       }),
14     ])
15     expect(decryptedCommit).toBeDefined()
16   })
18   it('should return byte size', () => {
19     const decryptedCommit = new DecryptedCommit('commitId', [
20       new DecryptedMessage({
21         content: new Uint8Array([1, 2, 3]),
22         signature: new Uint8Array([4, 5, 6]),
23         authorAddress: 'authorAddress',
24         aad: 'aad',
25         timestamp: 123456,
26       }),
27     ])
28     expect(decryptedCommit.byteSize).toBe(22)
29   })
31   it('should return number of updates', () => {
32     const decryptedCommit = new DecryptedCommit('commitId', [
33       new DecryptedMessage({
34         content: new Uint8Array([1, 2, 3]),
35         signature: new Uint8Array([4, 5, 6]),
36         authorAddress: 'authorAddress',
37         aad: 'aad',
38         timestamp: 123456,
39       }),
40     ])
41     expect(decryptedCommit.numberOfUpdates()).toBe(1)
42   })
44   it('should return needs squash', () => {
45     const decryptedCommit = new DecryptedCommit('commitId', [
46       new DecryptedMessage({
47         content: new Uint8Array([1, 2, 3]),
48         signature: new Uint8Array([4, 5, 6]),
49         authorAddress: 'authorAddress',
50         aad: 'aad',
51         timestamp: 123456,
52       }),
53     ])
54     expect(decryptedCommit.needsSquash()).toBe(false)
55   })