2 GetAssociatedEncryptionDataForRealtimeMessage,
3 GetAssociatedEncryptionDataForComment,
5 } from './GetAdditionalEncryptionData'
7 describe('GetAdditionalEncryptionData', () => {
8 describe('GetAssociatedEncryptionDataForRealtimeMessage', () => {
9 it('should format data with author address when present', () => {
12 authorAddress: 'test@example.com',
13 timestamp: 1234567890,
16 const result = GetAssociatedEncryptionDataForRealtimeMessage(metadata)
17 expect(result).toBe('1.test@example.com.1234567890')
20 it('should format data with "anonymous" when author address is undefined', () => {
23 authorAddress: undefined,
24 timestamp: 1234567890,
27 const result = GetAssociatedEncryptionDataForRealtimeMessage(metadata)
28 expect(result).toBe('1.anonymous.1234567890')
31 it('should handle different version numbers', () => {
34 authorAddress: 'test@example.com',
35 timestamp: 1234567890,
38 const result = GetAssociatedEncryptionDataForRealtimeMessage(metadata)
39 expect(result).toBe('2.test@example.com.1234567890')
43 describe('GetAssociatedEncryptionDataForComment', () => {
44 it('should format data with author address when present', () => {
46 authorAddress: 'test@example.com',
50 const result = GetAssociatedEncryptionDataForComment(metadata)
51 expect(result).toBe('test@example.com.mark-123')
54 it('should format data with "anonymous" when author address is undefined', () => {
56 authorAddress: undefined,
60 const result = GetAssociatedEncryptionDataForComment(metadata)
61 expect(result).toBe('anonymous.mark-123')
64 it('should handle different markId formats', () => {
66 authorAddress: 'test@example.com',
67 markId: 'uuid-123-456-789',
70 const result = GetAssociatedEncryptionDataForComment(metadata)
71 expect(result).toBe('test@example.com.uuid-123-456-789')
75 describe('isAnonymousComment', () => {
76 it('should return true if the AAD is anonymous', () => {
77 expect(isAnonymousComment('anonymous.mark-123')).toBe(true)
80 it('should return false if the AAD is not anonymous', () => {
81 expect(isAnonymousComment('test@example.com.mark-123')).toBe(false)