mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-29 13:00:18 +00:00
companion: fix test
This commit is contained in:
parent
1e5e54bc9d
commit
bfd5d217fe
1 changed files with 33 additions and 12 deletions
|
|
@ -2,10 +2,17 @@ const fs = require('fs')
|
|||
|
||||
class MockPurest {
|
||||
constructor (opts) {
|
||||
const methodsToMock = ['query', 'select', 'where', 'qs', 'auth', 'get', 'put', 'post', 'options', 'json']
|
||||
const methodsToMock = ['query', 'select', 'where', 'qs', 'auth', 'json']
|
||||
const httpMethodsToMock = ['get', 'put', 'post', 'options', 'head']
|
||||
methodsToMock.forEach((item) => {
|
||||
this[item] = () => this
|
||||
})
|
||||
httpMethodsToMock.forEach((item) => {
|
||||
this[item] = (url) => {
|
||||
this._requestUrl = url
|
||||
return this
|
||||
}
|
||||
})
|
||||
this.opts = opts
|
||||
}
|
||||
|
||||
|
|
@ -13,24 +20,38 @@ class MockPurest {
|
|||
if (typeof done === 'function') {
|
||||
const responses = {
|
||||
dropbox: {
|
||||
hash: '0a9f95a989dd4b1851f0103c31e304ce',
|
||||
user_email: 'foo@bar.com',
|
||||
email: 'foo@bar.com',
|
||||
entries: [{ rev: 'f24234cd4' }]
|
||||
default: {
|
||||
hash: '0a9f95a989dd4b1851f0103c31e304ce',
|
||||
user_email: 'foo@bar.com',
|
||||
email: 'foo@bar.com',
|
||||
entries: [{ rev: 'f24234cd4' }]
|
||||
}
|
||||
},
|
||||
drive: {
|
||||
kind: 'drive#fileList',
|
||||
etag: '"bcIyJ9A3gXa8oTYmz6nzAjQd-lY/eQc3WbZHkXpcItNyGKDuKXM_bNY"',
|
||||
files: [{
|
||||
'files/README.md': {
|
||||
id: '0B2x-PmqQHSKdT013TE1VVjZ3TWs',
|
||||
mimeType: 'image/jpg',
|
||||
ownedByMe: true,
|
||||
permissions: [{ role: 'owner', emailAddress: 'ife@bala.com' }]
|
||||
}],
|
||||
size: 300
|
||||
permissions: [{ role: 'owner', emailAddress: 'ife@bala.com' }],
|
||||
size: 300,
|
||||
kind: 'drive#file',
|
||||
etag: '"bcIyJ9A3gXa8oTYmz6nzAjQd-lY/eQc3WbZHkXpcItNyGKDuKXM_bNY"'
|
||||
},
|
||||
default: {
|
||||
kind: 'drive#fileList',
|
||||
etag: '"bcIyJ9A3gXa8oTYmz6nzAjQd-lY/eQc3WbZHkXpcItNyGKDuKXM_bNY"',
|
||||
files: [{
|
||||
id: '0B2x-PmqQHSKdT013TE1VVjZ3TWs',
|
||||
mimeType: 'image/jpg',
|
||||
ownedByMe: true,
|
||||
permissions: [{ role: 'owner', emailAddress: 'ife@bala.com' }]
|
||||
}],
|
||||
size: 300
|
||||
}
|
||||
}
|
||||
}
|
||||
const body = responses[this.opts.providerName]
|
||||
const providerResponses = responses[this.opts.providerName]
|
||||
const body = providerResponses[this._requestUrl] || providerResponses.default
|
||||
done(null, { body, statusCode: 200 }, body)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue