You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
describe('/file/upload file, function () { it('Uploadfile',function(done){//mock the upload of the filevarnock=require('nock');nock('https://www.googleapis.com').post('/upload/drive/v3/files?uploadType=multipart').reply(200,{id: 'theIdOfTheFile'});//in our example we reply the id from google drivevarform=newFormData();form.append('id','123');// your form dataform.append('selectedFile',fs.createReadStream('./test/fixtures/file.txt'));streamToPromise(form).then(function(payload){Server.init(0,function(err,server){expect(err).to.not.exist();varoptions={method: "POST",url: "/file/upload",headers: form.getHeaders(),payload: payload,credentials: {id: "12","name": "Some name",valid: true}};server.inject(options,function(res){//redirect to the candidate pageexpect(res.statusCode).to.equal(302);expect(res.headers.location).to.equal('/candidate/123');server.stop(done);});});})});});
hapijs/hapi#1543
https://gist.github.com/Couto/127ca8a6bd28ecc4a084
https://www.npmjs.com/package/form-data
full example WIP
The text was updated successfully, but these errors were encountered: