2
1

video-change-ownership.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import * as request from 'supertest'
  2. function changeVideoOwnership (url: string, token: string, videoId: number | string, username, expectedStatus = 204) {
  3. const path = '/api/v1/videos/' + videoId + '/give-ownership'
  4. return request(url)
  5. .post(path)
  6. .set('Accept', 'application/json')
  7. .set('Authorization', 'Bearer ' + token)
  8. .send({ username })
  9. .expect(expectedStatus)
  10. }
  11. function getVideoChangeOwnershipList (url: string, token: string) {
  12. const path = '/api/v1/videos/ownership'
  13. return request(url)
  14. .get(path)
  15. .query({ sort: '-createdAt' })
  16. .set('Accept', 'application/json')
  17. .set('Authorization', 'Bearer ' + token)
  18. .expect(200)
  19. .expect('Content-Type', /json/)
  20. }
  21. function acceptChangeOwnership (url: string, token: string, ownershipId: string, channelId: number, expectedStatus = 204) {
  22. const path = '/api/v1/videos/ownership/' + ownershipId + '/accept'
  23. return request(url)
  24. .post(path)
  25. .set('Accept', 'application/json')
  26. .set('Authorization', 'Bearer ' + token)
  27. .send({ channelId })
  28. .expect(expectedStatus)
  29. }
  30. function refuseChangeOwnership (url: string, token: string, ownershipId: string, expectedStatus = 204) {
  31. const path = '/api/v1/videos/ownership/' + ownershipId + '/refuse'
  32. return request(url)
  33. .post(path)
  34. .set('Accept', 'application/json')
  35. .set('Authorization', 'Bearer ' + token)
  36. .expect(expectedStatus)
  37. }
  38. // ---------------------------------------------------------------------------
  39. export {
  40. changeVideoOwnership,
  41. getVideoChangeOwnershipList,
  42. acceptChangeOwnership,
  43. refuseChangeOwnership
  44. }