-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
252 additions
and
127 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { PublicChannelStorage } from '@quiet/types' | ||
import { generateChannelId } from './channelAddress' | ||
import { userCreatedChannelMessage, userJoinedMessage, verifyUserInfoMessage } from './messages' | ||
|
||
describe('messages helper', () => { | ||
const username = 'johnny' | ||
|
||
const generalChannel: PublicChannelStorage = { | ||
name: 'general', | ||
description: 'Welcome to #general', | ||
timestamp: 1, | ||
owner: username, | ||
id: generateChannelId('general'), | ||
messages: { ids: [], entities: {} }, | ||
} | ||
|
||
const sportChannel: PublicChannelStorage = { | ||
name: 'sport', | ||
description: 'Welcome to #sport', | ||
timestamp: 1, | ||
owner: username, | ||
id: generateChannelId('sport'), | ||
messages: { ids: [], entities: {} }, | ||
} | ||
it('userCreatedChannelMessage', () => { | ||
const expectedMessage = '@johnny created #sport' | ||
const message = userCreatedChannelMessage(username, sportChannel.name) | ||
expect(message).toEqual(expectedMessage) | ||
}) | ||
|
||
it('userJoinedMessage', () => { | ||
const expectedMessage = | ||
'**@johnny** has joined and will be registered soon. 🎉 [Learn more](https://github.com/TryQuiet/quiet/wiki/Quiet-FAQ#how-does-username-registration-work)' | ||
const message = userJoinedMessage(username) | ||
expect(message).toEqual(expectedMessage) | ||
}) | ||
|
||
it('verifyUserInfoMessage - general channel', () => { | ||
const expectedMessage = | ||
'**@johnny** has joined and will be registered soon. 🎉 [Learn more](https://github.com/TryQuiet/quiet/wiki/Quiet-FAQ#how-does-username-registration-work)' | ||
const message = verifyUserInfoMessage(username, generalChannel) | ||
expect(message).toEqual(expectedMessage) | ||
}) | ||
|
||
it('verifyUserInfoMessage - other channel', () => { | ||
const expectedMessage = '@johnny created #sport' | ||
const message = verifyUserInfoMessage(username, sportChannel) | ||
expect(message).toEqual(expectedMessage) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { PublicChannelStorage } from '@quiet/types' | ||
|
||
export const userCreatedChannelMessage = (username: string, channelName: string) => | ||
`@${username} created #${channelName}` | ||
|
||
export const userJoinedMessage = (username: string) => | ||
`**@${username}** has joined and will be registered soon. 🎉 [Learn more](https://github.com/TryQuiet/quiet/wiki/Quiet-FAQ#how-does-username-registration-work)` | ||
|
||
export const verifyUserInfoMessage = (username: string, channel: PublicChannelStorage) => { | ||
if (channel.name === 'general') { | ||
return userJoinedMessage(username) | ||
} else { | ||
return userCreatedChannelMessage(username, channel.name) | ||
} | ||
} |
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
Oops, something went wrong.