drive.js 1.3 KB

1234567891011121314151617181920212223
  1. const nock = require('nock')
  2. const defaults = require('./constants')
  3. module.exports.expects = {}
  4. module.exports.nockGoogleDriveAboutCall = () => nock('https://www.googleapis.com').get((uri) => uri.includes('about')).reply(200, { user: { emailAddress: 'john.doe@transloadit.com' } })
  5. module.exports.nockGoogleDownloadFile = ({ times = 1 } = {}) => {
  6. nock('https://www.googleapis.com').get(`/drive/v3/files/${defaults.ITEM_ID}?fields=kind%2Cid%2CimageMediaMetadata%2Cname%2CmimeType%2CownedByMe%2Csize%2CmodifiedTime%2CiconLink%2CthumbnailLink%2CteamDriveId%2CvideoMediaMetadata%2CshortcutDetails%28targetId%2CtargetMimeType%29&supportsAllDrives=true`).times(times).reply(200, {
  7. kind: 'drive#file',
  8. id: defaults.ITEM_ID,
  9. name: 'MY DUMMY FILE NAME.mp4',
  10. mimeType: 'video/mp4',
  11. iconLink: 'https://drive-thirdparty.googleusercontent.com/16/type/video/mp4',
  12. thumbnailLink: 'https://DUMMY-THUMBNAIL.com/file.jpg',
  13. modifiedTime: '2016-07-10T20:00:08.096Z',
  14. ownedByMe: true,
  15. permissions: [{ role: 'owner', emailAddress: 'john.doe@transloadit.com' }],
  16. size: '758051',
  17. })
  18. nock('https://www.googleapis.com').get(`/drive/v3/files/${defaults.ITEM_ID}?alt=media&supportsAllDrives=true`).reply(200, {})
  19. module.exports.nockGoogleDriveAboutCall()
  20. }