forked from zulip/zulip-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
51 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,36 @@ describe('chatReducers', () => { | |
}); | ||
}); | ||
|
||
test('Message sent to self is stored correctly', () => { | ||
const narrowWithSelfStr = JSON.stringify(privateNarrow('[email protected]')); | ||
const initialState = { | ||
messages: { | ||
[homeNarrowStr]: [], | ||
[narrowWithSelfStr]: [], | ||
} | ||
}; | ||
const message = { | ||
id: 1, | ||
display_recipient: [{ email: '[email protected]' }] | ||
}; | ||
const action = { | ||
type: EVENT_NEW_MESSAGE, | ||
selfEmail: '[email protected]', | ||
message, | ||
}; | ||
const expectedState = { | ||
messages: { | ||
[homeNarrowStr]: [message], | ||
[narrowWithSelfStr]: [message], | ||
} | ||
}; | ||
|
||
const newState = chatReducers(initialState, action); | ||
|
||
expect(newState).toEqual(expectedState); | ||
expect(newState).not.toBe(initialState); | ||
}); | ||
|
||
test('appends stream message to all cached narrows that match', () => { | ||
const initialState = { | ||
messages: { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,6 +147,18 @@ describe('isMessageInNarrow', () => { | |
expect(isMessageInNarrow(message, narrow, '[email protected]')).toBe(true); | ||
}); | ||
|
||
test('message to self is in "private" narrow with self', () => { | ||
const message = { | ||
type: 'private', | ||
display_recipient: [ | ||
{ email: '[email protected]' }, | ||
], | ||
}; | ||
const narrow = privateNarrow('[email protected]'); | ||
|
||
expect(isMessageInNarrow(message, narrow, '[email protected]')).toBe(true); | ||
}); | ||
|
||
test('message with type "private" is in group narrow if all recipients match ', () => { | ||
const message = { | ||
type: 'private', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters