Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Search.prototype.new = function (query, params, callback) {
var keys = Object.keys(params);
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i];

uri += '&'+key+'='+params[key];
}
}
Expand All @@ -107,7 +107,7 @@ Search.prototype.new = function (query, params, callback) {

callback(null, res.body);
});
}
};


// Files Resource
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"superagent": "~0.18.0"
},
"devDependencies": {
"prova": "latest"
"nock": "latest",
"prova": "latest",
}
}
27 changes: 25 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var Box = require('../lib/'),
test = require('prova'),
nock = require('nock'),
path = require('path'),
async = require('async');
test = require('prova');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import was not used.


var fs = require('fs'),
request = require('superagent');
Expand All @@ -10,3 +10,26 @@ var fs = require('fs'),
var box = new Box({
access_token: 'null'
});

test('file.upload without custom filename', function (t) {
t.plan(1);
var boxFileId = 'box-file-id',
uploadFileName = 'a.txt',
filepath = __dirname + '/' + uploadFileName,
folderId = '1234';

nock(box.options.upload_url)
.post('/files/content', function(body) {
folderIdParamRegex = 'name="parent_id"' + folderId;
filenameParamRegex = 'name="filename"; filename="' + uploadFileName + '"';
return body.match(folderIdParamRegex) && body.match(filenameParamRegex);
})
.reply(201, { id: boxFileId });

box.files.upload(filepath, folderId, function(err, success) {
if (err) {
throw err;
}
t.equal(success.id, boxFileId);
});
});