video.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { VideoMetadata, PublishedBeforeJoystream } from '../proto/Video_pb'
  2. import { assert, expect } from 'chai'
  3. describe('Video Metadata', () => {
  4. it('Create Video Metadata', () => {
  5. const meta = new VideoMetadata()
  6. const title = 'Video Title'
  7. const description = 'Video Description'
  8. const duration = 100
  9. meta.setTitle(title)
  10. meta.setDescription(description)
  11. meta.setDuration(duration)
  12. // Test optional field
  13. expect(meta.hasPublishedBeforeJoystream()).equals(false, 'PublishedBeforeJoystream field should NOT be set')
  14. // Set published before joystream field
  15. const published = new PublishedBeforeJoystream()
  16. const isPublished = true
  17. const timestamp = 10000
  18. published.setIsPublished(isPublished)
  19. published.setTimestamp(timestamp)
  20. meta.setPublishedBeforeJoystream(published)
  21. // Field show now be set
  22. expect(meta.hasPublishedBeforeJoystream()).equals(true, 'PublishedBeforeJoystream field should be set')
  23. assert.deepEqual(VideoMetadata.deserializeBinary(meta.serializeBinary()), meta)
  24. assert.deepEqual(meta.toObject(), {
  25. title,
  26. description,
  27. duration,
  28. mediaPixelHeight: undefined,
  29. mediaPixelWidth: undefined,
  30. mediaType: undefined,
  31. language: undefined,
  32. license: undefined,
  33. publishedBeforeJoystream: { isPublished, timestamp },
  34. hasMarketing: undefined,
  35. isPublic: undefined,
  36. isExplicit: undefined,
  37. })
  38. })
  39. })