mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-05 07:13:11 +00:00
27 lines
808 B
TypeScript
27 lines
808 B
TypeScript
import { expect } from 'chai';
|
|
import fc from 'fast-check';
|
|
|
|
import { ChatMessage } from './chat_message';
|
|
|
|
describe('Chat Message', function () {
|
|
it('Chat message round trip binary serialization', function () {
|
|
fc.assert(
|
|
fc.property(
|
|
fc.date({ min: new Date(0) }),
|
|
fc.string(),
|
|
fc.string(),
|
|
(timestamp, nick, message) => {
|
|
const msg = new ChatMessage(timestamp, nick, message);
|
|
const buf = msg.encode();
|
|
const actual = ChatMessage.decode(buf);
|
|
|
|
// Date.toString does not include ms, as we loose this precision by design
|
|
expect(actual.timestamp.toString()).to.eq(timestamp.toString());
|
|
expect(actual.nick).to.eq(nick);
|
|
expect(actual.message).to.eq(message);
|
|
}
|
|
)
|
|
);
|
|
});
|
|
});
|