channel.ts 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. import { ChannelMetadata } from '../src'
  2. import { assert } from 'chai'
  3. import { encodeDecode, metaToObject } from '../src/utils'
  4. import Long from 'long'
  5. describe('Channel Metadata', () => {
  6. it('Message', () => {
  7. const channel = {
  8. title: 'title',
  9. description: 'description',
  10. isPublic: false,
  11. language: 'fr',
  12. avatarPhoto: 0,
  13. coverPhoto: 1,
  14. category: Long.fromNumber(100, true),
  15. }
  16. const channelMessage = new ChannelMetadata(channel)
  17. assert.deepEqual(metaToObject(ChannelMetadata, channelMessage), { ...channel, category: '100' })
  18. assert.deepEqual(encodeDecode(ChannelMetadata, channel), { ...channel, category: '100' })
  19. })
  20. it('Channel Metadata: Category as number', () => {
  21. const channel = { category: 100 as any }
  22. const channelMessage = new ChannelMetadata(channel)
  23. ChannelMetadata.verify(channelMessage)
  24. assert.deepEqual(metaToObject(ChannelMetadata, channelMessage), { ...channel, category: '100' })
  25. assert.deepEqual(encodeDecode(ChannelMetadata, channel), { ...channel, category: '100' })
  26. })
  27. })