-
Notifications
You must be signed in to change notification settings - Fork 18
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
2 changed files
with
84 additions
and
1 deletion.
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
61 changes: 61 additions & 0 deletions
61
packages/messenger-widget/src/hooks/messages/renderer/renderMessage.test.ts
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,61 @@ | ||
import { | ||
getMockDeliveryServiceProfile, | ||
MockDeliveryServiceProfile, | ||
MockedUserProfile, | ||
MockMessageFactory, | ||
mockUserProfile, | ||
} from '@dm3-org/dm3-lib-test-helper'; | ||
import { ethers } from 'ethers'; | ||
import { renderMessage } from './renderMessage'; | ||
|
||
describe('Render Message', () => { | ||
let sender: MockedUserProfile; | ||
let receiver: MockedUserProfile; | ||
let ds1: MockDeliveryServiceProfile; | ||
|
||
beforeEach(async () => { | ||
sender = await mockUserProfile( | ||
ethers.Wallet.createRandom(), | ||
'alice.eth', | ||
['ds1.eth'], | ||
); | ||
receiver = await mockUserProfile( | ||
ethers.Wallet.createRandom(), | ||
'bob.eth', | ||
['ds1.eth', 'ds2.eth'], | ||
); | ||
ds1 = await getMockDeliveryServiceProfile( | ||
ethers.Wallet.createRandom(), | ||
'http://ds1.api', | ||
); | ||
}); | ||
describe('edit message', () => { | ||
it('NEW EDIT', async () => { | ||
const mockMessageFactory = MockMessageFactory( | ||
sender, | ||
receiver, | ||
ds1, | ||
); | ||
|
||
const ogMessage = await mockMessageFactory.createMessageModel( | ||
'Hello Dm3', | ||
'NEW', | ||
); | ||
|
||
const editMessage = await mockMessageFactory.createMessageModel( | ||
'Hello Dm3 Edit', | ||
'EDIT', | ||
ogMessage.envelop.metadata?.encryptedMessageHash, | ||
); | ||
|
||
const messages = [ogMessage, editMessage]; | ||
|
||
const res = renderMessage(messages); | ||
|
||
console.log(res[0].envelop); | ||
|
||
expect(res.length).toBe(1); | ||
expect(res[0].envelop.message.message).toBe('Hello Dm3 Edit'); | ||
}); | ||
}); | ||
}); |