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.
On message touch, do a narrow (zulip#333)
Implements zulip#306
- Loading branch information
1 parent
1c3aac4
commit 34ab1f9
Showing
7 changed files
with
103 additions
and
33 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
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
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
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ import { | |
topicNarrow, isTopicNarrow, | ||
searchNarrow, isSearchNarrow, | ||
isMessageInNarrow, | ||
narrowFromMessage, | ||
} from '../narrow'; | ||
|
||
describe('homeNarrow', () => { | ||
|
@@ -208,3 +209,53 @@ describe('isMessageInNarrow', () => { | |
expect(isMessageInNarrow(message, narrow)).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('narrowFromMessage', () => { | ||
test('message with single recipient, returns a private narrow', () => { | ||
const message = { | ||
display_recipient: [{ email: '[email protected]' }], | ||
}; | ||
const expectedNarrow = privateNarrow('[email protected]'); | ||
|
||
const actualNarrow = narrowFromMessage(message); | ||
|
||
expect(actualNarrow).toEqual(expectedNarrow); | ||
}); | ||
|
||
test('for message with multiple recipients, return a group narrow', () => { | ||
const message = { | ||
display_recipient: [ | ||
{ email: '[email protected]' }, | ||
{ email: '[email protected]' }, | ||
], | ||
}; | ||
const expectedNarrow = groupNarrow(['[email protected]', '[email protected]']); | ||
|
||
const actualNarrow = narrowFromMessage(message); | ||
|
||
expect(actualNarrow).toEqual(expectedNarrow); | ||
}); | ||
|
||
test('if recipient of a message is string, returns a stream narrow', () => { | ||
const message = { | ||
display_recipient: 'stream', | ||
}; | ||
const expectedNarrow = streamNarrow('stream'); | ||
|
||
const actualNarrow = narrowFromMessage(message); | ||
|
||
expect(actualNarrow).toEqual(expectedNarrow); | ||
}); | ||
|
||
test('if recipient is a string and there is a subject returns a topic narrow', () => { | ||
const message = { | ||
display_recipient: 'stream', | ||
subject: 'subject' | ||
}; | ||
const expectedNarrow = topicNarrow('stream', 'subject'); | ||
|
||
const actualNarrow = narrowFromMessage(message); | ||
|
||
expect(actualNarrow).toEqual(expectedNarrow); | ||
}); | ||
}); |
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