contentDirectoryModule.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { QueryNodeApi } from '../Api'
  2. import BN from 'bn.js'
  3. import { assert } from 'chai'
  4. import { Seat } from '@joystream/types/council'
  5. import { v4 as uuid } from 'uuid'
  6. import { Utils } from '../utils'
  7. import { Fixture } from '../Fixture'
  8. import { ChannelEntity } from '@joystream/cd-schemas/types/entities/ChannelEntity'
  9. import { VideoEntity } from '@joystream/cd-schemas/types/entities/VideoEntity'
  10. export class CreateChannelFixture implements Fixture {
  11. private api: QueryNodeApi
  12. public channelEntity: ChannelEntity
  13. public constructor(api: QueryNodeApi, channelEntity: ChannelEntity) {
  14. this.api = api
  15. this.channelEntity = channelEntity
  16. }
  17. public async runner(expectFailure: boolean): Promise<void> {
  18. await this.api.createChannelEntity(this.channelEntity)
  19. if (expectFailure) {
  20. throw new Error('Successful fixture run while expecting failure')
  21. }
  22. }
  23. }
  24. export class CreateVideoFixture implements Fixture {
  25. private api: QueryNodeApi
  26. public videoEntity: VideoEntity
  27. public constructor(api: QueryNodeApi, videoEntity: VideoEntity) {
  28. this.api = api
  29. this.videoEntity = videoEntity
  30. }
  31. public async runner(expectFailure: boolean): Promise<void> {
  32. await this.api.createVideoEntity(this.videoEntity)
  33. if (expectFailure) {
  34. throw new Error('Successful fixture run while expecting failure')
  35. }
  36. }
  37. }
  38. export class UpdateChannelFixture implements Fixture {
  39. private api: QueryNodeApi
  40. private channelUpdateInput: Record<string, any>
  41. private uniquePropValue: Record<string, any>
  42. public constructor(api: QueryNodeApi, channelUpdateInput: Record<string, any>, uniquePropValue: Record<string, any>) {
  43. this.api = api
  44. this.channelUpdateInput = channelUpdateInput
  45. this.uniquePropValue = uniquePropValue
  46. }
  47. public async runner(expectFailure: boolean): Promise<void> {
  48. await this.api.updateChannelEntity(this.channelUpdateInput, this.uniquePropValue)
  49. if (expectFailure) {
  50. throw new Error('Successful fixture run while expecting failure')
  51. }
  52. }
  53. }