Page MenuHomePhabricator

D9331.id31551.diff
No OneTemporary

D9331.id31551.diff

diff --git a/lib/types/message-types.test.js b/lib/types/message-types.test.js
--- a/lib/types/message-types.test.js
+++ b/lib/types/message-types.test.js
@@ -26,17 +26,238 @@
import { threadTypes } from './thread-types-enum.js';
import { messageSpecs } from '../shared/messages/message-specs.js';
+const textMessageInfo: RawTextMessageInfo = {
+ type: messageTypes.TEXT,
+ localID: 'local1',
+ threadID: '10001',
+ creatorID: '123',
+ time: 10000,
+ text: 'This is a text message',
+ id: '1',
+};
+const createThreadMessageInfo: RawCreateThreadMessageInfo = {
+ type: 1,
+ threadID: '10001',
+ creatorID: '123',
+ time: 10000,
+ initialThreadState: {
+ type: threadTypes.COMMUNITY_ROOT,
+ name: 'Random Thread',
+ parentThreadID: '10000',
+ color: '#FFFFFF',
+ memberIDs: ['1', '2', '3'],
+ },
+ id: '1',
+};
+const addMembersMessageInfo: RawAddMembersMessageInfo = {
+ type: messageTypes.ADD_MEMBERS,
+ threadID: '10001',
+ creatorID: '123',
+ time: 10000,
+ addedUserIDs: ['4', '5'],
+ id: '1',
+};
+const createSubthreadMessageInfo: RawCreateSubthreadMessageInfo = {
+ type: messageTypes.CREATE_SUB_THREAD,
+ threadID: '10001',
+ creatorID: '123',
+ time: 10000,
+ childThreadID: '10002',
+ id: '1',
+};
+const changeSettingsMessageInfo: RawChangeSettingsMessageInfo = {
+ type: messageTypes.CHANGE_SETTINGS,
+ threadID: '10000',
+ creatorID: '123',
+ time: 10000,
+ field: 'color',
+ value: '#FFFFFF',
+ id: '1',
+};
+const removeMembersMessageInfo: RawRemoveMembersMessageInfo = {
+ type: messageTypes.REMOVE_MEMBERS,
+ threadID: '10000',
+ creatorID: '123',
+ time: 10000,
+ removedUserIDs: ['1', '2', '3'],
+ id: '1',
+};
+const changeRoleMessageinfo: RawChangeRoleMessageInfo = {
+ type: messageTypes.CHANGE_ROLE,
+ threadID: '10000',
+ creatorID: '123',
+ time: 10000,
+ userIDs: ['1', '2', '3'],
+ newRole: '101',
+ roleName: 'Moderators',
+ id: '1',
+};
+const leaveThreadMessageInfo: RawLeaveThreadMessageInfo = {
+ type: messageTypes.LEAVE_THREAD,
+ threadID: '10000',
+ creatorID: '123',
+ time: 10000,
+ id: '1',
+};
+const joinThreadMessageInfo: RawJoinThreadMessageInfo = {
+ type: messageTypes.JOIN_THREAD,
+ threadID: '10000',
+ creatorID: '123',
+ time: 10000,
+ id: '1',
+};
+const createEntryMessageInfo: RawCreateEntryMessageInfo = {
+ type: messageTypes.CREATE_ENTRY,
+ threadID: '10000',
+ creatorID: '123',
+ time: 10000,
+ entryID: '001',
+ date: '2018-01-01',
+ text: 'This is a calendar entry',
+ id: '1',
+};
+const editEntryMessageInfo: RawEditEntryMessageInfo = {
+ type: messageTypes.EDIT_ENTRY,
+ threadID: '10000',
+ creatorID: '123',
+ time: 10000,
+ entryID: '001',
+ date: '2018-01-01',
+ text: 'This is an edited calendar entry',
+ id: '1',
+};
+const deleteEntryMessageInfo: RawDeleteEntryMessageInfo = {
+ type: messageTypes.DELETE_ENTRY,
+ threadID: '10000',
+ creatorID: '123',
+ time: 10000,
+ entryID: '001',
+ date: '2018-01-01',
+ text: 'This is a deleted calendar entry',
+ id: '1',
+};
+const restoreEntryMessageInfo: RawRestoreEntryMessageInfo = {
+ type: messageTypes.RESTORE_ENTRY,
+ threadID: '10000',
+ creatorID: '123',
+ time: 10000,
+ entryID: '001',
+ date: '2018-01-01',
+ text: 'This is a restored calendar entry',
+ id: '1',
+};
+const updateRelationshipMessageInfo: RawUpdateRelationshipMessageInfo = {
+ type: messageTypes.UPDATE_RELATIONSHIP,
+ threadID: '10000',
+ creatorID: '123',
+ targetID: '456',
+ time: 10000,
+ operation: 'request_sent',
+ id: '1',
+};
+const imageMessageInfo: RawImagesMessageInfo = {
+ type: messageTypes.IMAGES,
+ localID: 'local1',
+ threadID: '10001',
+ creatorID: '123',
+ time: 10000,
+ media: [
+ {
+ id: '1',
+ uri: 'https://example.com/image1.jpg',
+ type: 'photo',
+ dimensions: {
+ height: 100,
+ width: 100,
+ },
+ thumbHash: '1234567890',
+ },
+ ],
+ id: '1',
+};
+const mediaMessageInfo: RawMediaMessageInfo = {
+ type: messageTypes.MULTIMEDIA,
+ localID: 'local1',
+ threadID: '10001',
+ creatorID: '123',
+ time: 10000,
+ media: [
+ {
+ id: '1',
+ uri: 'https://example.com/image1.jpg',
+ type: 'photo',
+ dimensions: {
+ height: 100,
+ width: 100,
+ },
+ thumbHash: '1234567890',
+ },
+ ],
+ id: '1',
+};
+const sidebarSourceMessageInfo: RawSidebarSourceMessageInfo = {
+ type: messageTypes.SIDEBAR_SOURCE,
+ threadID: '10000',
+ creatorID: '123',
+ time: 10000,
+ sourceMessage: {
+ type: messageTypes.TEXT,
+ localID: 'local1',
+ threadID: '10001',
+ creatorID: '123',
+ time: 10000,
+ text: 'This is a text message',
+ id: '1',
+ },
+ id: '1',
+};
+const createSidebarMessageInfo: RawCreateSidebarMessageInfo = {
+ type: messageTypes.CREATE_SIDEBAR,
+ threadID: '10000',
+ creatorID: '123',
+ time: 10000,
+ sourceMessageAuthorID: '123',
+ initialThreadState: {
+ name: 'Random Thread',
+ parentThreadID: '10000',
+ color: '#FFFFFF',
+ memberIDs: ['1', '2', '3'],
+ },
+ id: '1',
+};
+const reactionMessageInfo: RawReactionMessageInfo = {
+ type: messageTypes.REACTION,
+ localID: 'local1',
+ threadID: '10001',
+ creatorID: '123',
+ time: 10000,
+ targetMessageID: '1',
+ reaction: 'like',
+ action: 'add_reaction',
+ id: '1',
+};
+const editMessageInfo: RawEditMessageInfo = {
+ type: messageTypes.EDIT_MESSAGE,
+ threadID: '10000',
+ creatorID: '123',
+ time: 10000,
+ targetMessageID: '1',
+ text: 'This is an edited message',
+ id: '1',
+};
+const togglePinMessageInfo: RawTogglePinMessageInfo = {
+ type: messageTypes.TOGGLE_PIN,
+ threadID: '10000',
+ targetMessageID: '1',
+ action: 'pin',
+ pinnedContent: 'a message',
+ creatorID: '123',
+ time: 10000,
+ id: '1',
+};
+
describe('isInvalidSidebarSource & canBeSidebarSource', () => {
it('should return false for RawTextMessageInfo', () => {
- const textMessageInfo: RawTextMessageInfo = {
- type: messageTypes.TEXT,
- localID: 'local1',
- threadID: '10001',
- creatorID: '123',
- time: 10000,
- text: 'This is a text message',
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.TEXT];
const shouldBeInvalidSidebarSource =
@@ -48,20 +269,6 @@
});
it('should return false for RawCreateThreadMessageInfo', () => {
- const createThreadMessageInfo: RawCreateThreadMessageInfo = {
- type: 1,
- threadID: '10001',
- creatorID: '123',
- time: 10000,
- initialThreadState: {
- type: threadTypes.COMMUNITY_ROOT,
- name: 'Random Thread',
- parentThreadID: '10000',
- color: '#FFFFFF',
- memberIDs: ['1', '2', '3'],
- },
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.CREATE_THREAD];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
@@ -76,14 +283,6 @@
});
it('should return false for RawAddMembersMessageInfo', () => {
- const addMembersMessageInfo: RawAddMembersMessageInfo = {
- type: messageTypes.ADD_MEMBERS,
- threadID: '10001',
- creatorID: '123',
- time: 10000,
- addedUserIDs: ['4', '5'],
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.ADD_MEMBERS];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
@@ -98,14 +297,6 @@
});
it('should return false for RawCreateSubthreadMessageInfo', () => {
- const createSubthreadMessageInfo: RawCreateSubthreadMessageInfo = {
- type: messageTypes.CREATE_SUB_THREAD,
- threadID: '10001',
- creatorID: '123',
- time: 10000,
- childThreadID: '10002',
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.CREATE_SUB_THREAD];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
@@ -120,15 +311,6 @@
});
it('should return false for RawChangeSettingsMessageInfo', () => {
- const changeSettingsMessageInfo: RawChangeSettingsMessageInfo = {
- type: messageTypes.CHANGE_SETTINGS,
- threadID: '10000',
- creatorID: '123',
- time: 10000,
- field: 'color',
- value: '#FFFFFF',
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.CHANGE_SETTINGS];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
@@ -143,14 +325,6 @@
});
it('should return false for RawRemoveMembersMessageInfo', () => {
- const removeMembersMessageInfo: RawRemoveMembersMessageInfo = {
- type: messageTypes.REMOVE_MEMBERS,
- threadID: '10000',
- creatorID: '123',
- time: 10000,
- removedUserIDs: ['1', '2', '3'],
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.REMOVE_MEMBERS];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
@@ -165,16 +339,6 @@
});
it('should return false for RawChangeRoleMessageInfo', () => {
- const changeRoleMessageinfo: RawChangeRoleMessageInfo = {
- type: messageTypes.CHANGE_ROLE,
- threadID: '10000',
- creatorID: '123',
- time: 10000,
- userIDs: ['1', '2', '3'],
- newRole: '101',
- roleName: 'Moderators',
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.CHANGE_ROLE];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
@@ -189,13 +353,6 @@
});
it('should return false for RawLeaveThreadMessageInfo', () => {
- const leaveThreadMessageInfo: RawLeaveThreadMessageInfo = {
- type: messageTypes.LEAVE_THREAD,
- threadID: '10000',
- creatorID: '123',
- time: 10000,
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.LEAVE_THREAD];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
@@ -210,13 +367,6 @@
});
it('should return false for RawJoinThreadMessageInfo', () => {
- const joinThreadMessageInfo: RawJoinThreadMessageInfo = {
- type: messageTypes.JOIN_THREAD,
- threadID: '10000',
- creatorID: '123',
- time: 10000,
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.JOIN_THREAD];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
@@ -231,16 +381,6 @@
});
it('should return false for RawCreateEntryMessageInfo', () => {
- const createEntryMessageInfo: RawCreateEntryMessageInfo = {
- type: messageTypes.CREATE_ENTRY,
- threadID: '10000',
- creatorID: '123',
- time: 10000,
- entryID: '001',
- date: '2018-01-01',
- text: 'This is a calendar entry',
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.CREATE_ENTRY];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
@@ -255,16 +395,6 @@
});
it('should return false for RawEditEntryMessageInfo', () => {
- const editEntryMessageInfo: RawEditEntryMessageInfo = {
- type: messageTypes.EDIT_ENTRY,
- threadID: '10000',
- creatorID: '123',
- time: 10000,
- entryID: '001',
- date: '2018-01-01',
- text: 'This is an edited calendar entry',
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.EDIT_ENTRY];
const shouldBeInvalidSidebarSource =
@@ -277,16 +407,6 @@
});
it('should return false for RawDeleteEntryMessageInfo', () => {
- const deleteEntryMessageInfo: RawDeleteEntryMessageInfo = {
- type: messageTypes.DELETE_ENTRY,
- threadID: '10000',
- creatorID: '123',
- time: 10000,
- entryID: '001',
- date: '2018-01-01',
- text: 'This is a deleted calendar entry',
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.DELETE_ENTRY];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
@@ -301,16 +421,6 @@
});
it('should return false for RawRestoreEntryMessageInfo', () => {
- const restoreEntryMessageInfo: RawRestoreEntryMessageInfo = {
- type: messageTypes.RESTORE_ENTRY,
- threadID: '10000',
- creatorID: '123',
- time: 10000,
- entryID: '001',
- date: '2018-01-01',
- text: 'This is a restored calendar entry',
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.RESTORE_ENTRY];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
@@ -325,15 +435,6 @@
});
it('should return false for RawUpdateRelationshipMessageInfo', () => {
- const updateRelationshipMessageInfo: RawUpdateRelationshipMessageInfo = {
- type: messageTypes.UPDATE_RELATIONSHIP,
- threadID: '10000',
- creatorID: '123',
- targetID: '456',
- time: 10000,
- operation: 'request_sent',
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.UPDATE_RELATIONSHIP];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
@@ -348,26 +449,6 @@
});
it('should return false for RawImagesMessageInfo', () => {
- const imageMessageInfo: RawImagesMessageInfo = {
- type: messageTypes.IMAGES,
- localID: 'local1',
- threadID: '10001',
- creatorID: '123',
- time: 10000,
- media: [
- {
- id: '1',
- uri: 'https://example.com/image1.jpg',
- type: 'photo',
- dimensions: {
- height: 100,
- width: 100,
- },
- thumbHash: '1234567890',
- },
- ],
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.IMAGES];
const shouldBeInvalidSidebarSource =
@@ -379,26 +460,6 @@
});
it('should return false for RawMediaMessageInfo', () => {
- const mediaMessageInfo: RawMediaMessageInfo = {
- type: messageTypes.MULTIMEDIA,
- localID: 'local1',
- threadID: '10001',
- creatorID: '123',
- time: 10000,
- media: [
- {
- id: '1',
- uri: 'https://example.com/image1.jpg',
- type: 'photo',
- dimensions: {
- height: 100,
- width: 100,
- },
- thumbHash: '1234567890',
- },
- ],
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.MULTIMEDIA];
const shouldBeInvalidSidebarSource =
@@ -410,22 +471,6 @@
});
it('should return true for RawSidebarSourceMessageInfo', () => {
- const sidebarSourceMessageInfo: RawSidebarSourceMessageInfo = {
- type: messageTypes.SIDEBAR_SOURCE,
- threadID: '10000',
- creatorID: '123',
- time: 10000,
- sourceMessage: {
- type: messageTypes.TEXT,
- localID: 'local1',
- threadID: '10001',
- creatorID: '123',
- time: 10000,
- text: 'This is a text message',
- id: '1',
- },
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.SIDEBAR_SOURCE];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
@@ -440,20 +485,6 @@
});
it('should return false for RawCreateSidebarMessageInfo', () => {
- const createSidebarMessageInfo: RawCreateSidebarMessageInfo = {
- type: messageTypes.CREATE_SIDEBAR,
- threadID: '10000',
- creatorID: '123',
- time: 10000,
- sourceMessageAuthorID: '123',
- initialThreadState: {
- name: 'Random Thread',
- parentThreadID: '10000',
- color: '#FFFFFF',
- memberIDs: ['1', '2', '3'],
- },
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.CREATE_SIDEBAR];
const shouldBeInvalidSidebarSource = isInvalidSidebarSource(
@@ -468,17 +499,6 @@
});
it('should return true for RawReactionMessageInfo', () => {
- const reactionMessageInfo: RawReactionMessageInfo = {
- type: messageTypes.REACTION,
- localID: 'local1',
- threadID: '10001',
- creatorID: '123',
- time: 10000,
- targetMessageID: '1',
- reaction: 'like',
- action: 'add_reaction',
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.REACTION];
const shouldBeInvalidSidebarSource =
@@ -491,15 +511,6 @@
});
it('should return true for RawEditMessageInfo', () => {
- const editMessageInfo: RawEditMessageInfo = {
- type: messageTypes.EDIT_MESSAGE,
- threadID: '10000',
- creatorID: '123',
- time: 10000,
- targetMessageID: '1',
- text: 'This is an edited message',
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.EDIT_MESSAGE];
const shouldBeInvalidSidebarSource =
@@ -511,16 +522,6 @@
});
it('should return true for RawTogglePinMessageInfo', () => {
- const togglePinMessageInfo: RawTogglePinMessageInfo = {
- type: messageTypes.TOGGLE_PIN,
- threadID: '10000',
- targetMessageID: '1',
- action: 'pin',
- pinnedContent: 'a message',
- creatorID: '123',
- time: 10000,
- id: '1',
- };
const messageSpec = messageSpecs[messageTypes.TOGGLE_PIN];
const shouldBeInvalidSidebarSource =

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 9:31 PM (21 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2586396
Default Alt Text
D9331.id31551.diff (16 KB)

Event Timeline