const fs = require('fs')

class MockPurest {
  constructor (opts) {
    const methodsToMock = ['query', 'select', 'where', 'qs', 'auth', 'get', 'put', 'post', 'options', 'json']
    methodsToMock.forEach((item) => {
      this[item] = () => this
    })
    this.opts = opts
  }

  request (done) {
    if (typeof done === 'function') {
      const responses = {
        dropbox: {
          hash: '0a9f95a989dd4b1851f0103c31e304ce',
          user_email: 'foo@bar.com',
          email: 'foo@bar.com',
          entries: [{ rev: 'f24234cd4' }]
        },
        drive: {
          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]
      done(null, { body, statusCode: 200 }, body)
    }

    return this
  }

  on (evt, cb) {
    if (evt === 'response') {
      cb(fs.createReadStream('./README.md'))
    }
    return this
  }
}

module.exports = () => {
  return (options) => new MockPurest(options)
}

@@ -130,16 +130,55 @@
 'auth', 
+'json'%5D%0A    const httpMethodsToMock = %5B
 'get', '
@@ -199,28 +199,28 @@
 'options', '
-json
+head
 '%5D%0A    metho
@@ -285,16 +285,154 @@
 %0A    %7D)%0A
+    httpMethodsToMock.forEach((item) =%3E %7B%0A      this%5Bitem%5D = (url) =%3E %7B%0A        this._requestUrl = url%0A        return this%0A      %7D%0A    %7D)%0A
     this
@@ -547,24 +547,47 @@
  dropbox: %7B%0A
+          default: %7B%0A  
           ha
@@ -626,16 +626,18 @@
 304ce',%0A
+  
         
@@ -675,16 +675,18 @@
         
+  
 email: '
@@ -691,32 +691,34 @@
  'foo@bar.com',%0A
+  
           entrie
@@ -739,24 +739,36 @@
 4234cd4' %7D%5D%0A
+          %7D%0A
         %7D,%0A 
@@ -779,24 +779,412 @@
    drive: %7B%0A
+          'files/README.md': %7B%0A            id: '0B2x-PmqQHSKdT013TE1VVjZ3TWs',%0A            mimeType: 'image/jpg',%0A            ownedByMe: true,%0A            permissions: %5B%7B role: 'owner', emailAddress: 'ife@bala.com' %7D%5D,%0A            size: 300,%0A            kind: 'drive#file',%0A            etag: '%22bcIyJ9A3gXa8oTYmz6nzAjQd-lY/eQc3WbZHkXpcItNyGKDuKXM_bNY%22'%0A          %7D,%0A          default: %7B%0A  
           ki
@@ -1205,16 +1205,18 @@
 eList',%0A
+  
         
@@ -1294,16 +1294,18 @@
         
+ 
+ 
 files: %5B
@@ -1306,16 +1306,18 @@
 les: %5B%7B%0A
+  
         
@@ -1360,32 +1360,34 @@
 s',%0A            
+  
 mimeType: 'image
@@ -1397,32 +1397,34 @@
 g',%0A            
+ 
+ 
 ownedByMe: true,
@@ -1416,32 +1416,34 @@
 wnedByMe: true,%0A
+  
             perm
@@ -1497,24 +1497,26 @@
 ala.com' %7D%5D%0A
+  
           %7D%5D
@@ -1519,32 +1519,34 @@
   %7D%5D,%0A          
+  
 size: 300%0A      
@@ -1543,26 +1543,30 @@
 300%0A        
-%7D%0A
+  %7D%0A  
       %7D%0A    
@@ -1571,18 +1571,39 @@
     
-const body
+%7D%0A      const providerResponses
  = r
@@ -1635,16 +1635,100 @@
 erName%5D%0A
+      const body = providerResponses%5Bthis._requestUrl%5D %7C%7C providerResponses.default%0A
       do

fix test