js-waku/src/lib/waku_message.spec.ts
Franck Royer 5a967ecbcc
Avoid possible type name clash between js-waku and consuming apps
`Message` is a very generic name and JS does not offer strong namespace
boundaries. Using `WakuMessage` avoid name clashing with classes
of the consumer app.
2021-04-01 11:18:35 +11:00

29 lines
680 B
TypeScript

import fc from 'fast-check';
import { WakuMessage } from './waku_message';
describe('Waku Message', function () {
it('Waku message round trip binary serialization', function () {
fc.assert(
fc.property(fc.string(), (s) => {
const msg = WakuMessage.fromUtf8String(s);
const binary = msg.toBinary();
const actual = WakuMessage.decode(binary);
return actual.isEqualTo(msg);
})
);
});
it('Payload to utf-8', function () {
fc.assert(
fc.property(fc.string(), (s) => {
const msg = WakuMessage.fromUtf8String(s);
const utf8 = msg.utf8Payload();
return utf8 === s;
})
);
});
});