Changeset View
Changeset View
Standalone View
Standalone View
lib/utils/message-ops-utils.test.js
Show All 14 Lines | |||||
import type { RawCreateSidebarMessageInfo } from '../types/messages/create-sidebar.js'; | import type { RawCreateSidebarMessageInfo } from '../types/messages/create-sidebar.js'; | ||||
import type { RawCreateSubthreadMessageInfo } from '../types/messages/create-subthread.js'; | import type { RawCreateSubthreadMessageInfo } from '../types/messages/create-subthread.js'; | ||||
import type { RawCreateThreadMessageInfo } from '../types/messages/create-thread.js'; | import type { RawCreateThreadMessageInfo } from '../types/messages/create-thread.js'; | ||||
import type { RawDeleteEntryMessageInfo } from '../types/messages/delete-entry.js'; | import type { RawDeleteEntryMessageInfo } from '../types/messages/delete-entry.js'; | ||||
import type { RawEditEntryMessageInfo } from '../types/messages/edit-entry.js'; | import type { RawEditEntryMessageInfo } from '../types/messages/edit-entry.js'; | ||||
import type { RawImagesMessageInfo } from '../types/messages/images.js'; | import type { RawImagesMessageInfo } from '../types/messages/images.js'; | ||||
import type { RawJoinThreadMessageInfo } from '../types/messages/join-thread.js'; | import type { RawJoinThreadMessageInfo } from '../types/messages/join-thread.js'; | ||||
import type { RawLeaveThreadMessageInfo } from '../types/messages/leave-thread.js'; | import type { RawLeaveThreadMessageInfo } from '../types/messages/leave-thread.js'; | ||||
import type { RawLegacyUpdateRelationshipMessageInfo } from '../types/messages/legacy-update-relationship.js'; | |||||
import type { RawRemoveMembersMessageInfo } from '../types/messages/remove-members.js'; | import type { RawRemoveMembersMessageInfo } from '../types/messages/remove-members.js'; | ||||
import type { RawRestoreEntryMessageInfo } from '../types/messages/restore-entry.js'; | import type { RawRestoreEntryMessageInfo } from '../types/messages/restore-entry.js'; | ||||
import type { RawTextMessageInfo } from '../types/messages/text.js'; | import type { RawTextMessageInfo } from '../types/messages/text.js'; | ||||
import type { RawUpdateRelationshipMessageInfo } from '../types/messages/update-relationship.js'; | |||||
test('TEXT: rawMessageInfo -> clientDBMessageInfo -> rawMessageInfo', () => { | test('TEXT: rawMessageInfo -> clientDBMessageInfo -> rawMessageInfo', () => { | ||||
const rawTextMessageInfo: RawTextMessageInfo = { | const rawTextMessageInfo: RawTextMessageInfo = { | ||||
type: 0, | type: 0, | ||||
localID: 'local7', | localID: 'local7', | ||||
threadID: '85466', | threadID: '85466', | ||||
text: 'Hello world', | text: 'Hello world', | ||||
creatorID: '85435', | creatorID: '85435', | ||||
▲ Show 20 Lines • Show All 279 Lines • ▼ Show 20 Lines | test('IMAGES (local): rawMessageInfo -> clientDBMessageInfo -> rawMessageInfo', () => { | ||||
expect( | expect( | ||||
translateClientDBMessageInfoToRawMessageInfo( | translateClientDBMessageInfoToRawMessageInfo( | ||||
translateRawMessageInfoToClientDBMessageInfo(localRawImagesMessageInfo), | translateRawMessageInfoToClientDBMessageInfo(localRawImagesMessageInfo), | ||||
), | ), | ||||
).toStrictEqual(localRawImagesMessageInfo); | ).toStrictEqual(localRawImagesMessageInfo); | ||||
}); | }); | ||||
test('LEGACY_UPDATE_RELATIONSHIP: rawMessageInfo -> clientDBMessageInfo -> rawMessageInfo', () => { | test('LEGACY_UPDATE_RELATIONSHIP: rawMessageInfo -> clientDBMessageInfo -> rawMessageInfo', () => { | ||||
const rawUpdateRelationshipMessageInfo: RawUpdateRelationshipMessageInfo = { | const rawUpdateRelationshipMessageInfo: RawLegacyUpdateRelationshipMessageInfo = | ||||
{ | |||||
type: 16, | type: 16, | ||||
id: '85651', | id: '85651', | ||||
threadID: '85630', | threadID: '85630', | ||||
time: 1638235869690, | time: 1638235869690, | ||||
creatorID: '83809', | creatorID: '83809', | ||||
targetID: '85435', | targetID: '85435', | ||||
operation: 'request_accepted', | operation: 'request_accepted', | ||||
}; | }; | ||||
expect( | expect( | ||||
translateClientDBMessageInfoToRawMessageInfo( | translateClientDBMessageInfoToRawMessageInfo( | ||||
translateRawMessageInfoToClientDBMessageInfo( | translateRawMessageInfoToClientDBMessageInfo( | ||||
rawUpdateRelationshipMessageInfo, | rawUpdateRelationshipMessageInfo, | ||||
), | ), | ||||
), | ), | ||||
).toStrictEqual(rawUpdateRelationshipMessageInfo); | ).toStrictEqual(rawUpdateRelationshipMessageInfo); | ||||
▲ Show 20 Lines • Show All 210 Lines • Show Last 20 Lines |