Skip to content

Commit

Permalink
Actually test HEAD promise resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
bhstahl committed Nov 27, 2015
1 parent de290a1 commit 2afecab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/handlers/HeadHandler.js
Expand Up @@ -22,7 +22,7 @@ class HeadHandler extends BaseHandler {
}

const file_name = match[1];
this.store.getOffset(file_name)
return this.store.getOffset(file_name)
.then(stats => {
res.setHeader('Upload-Offset', stats.size);
res.end();
Expand Down
2 changes: 1 addition & 1 deletion lib/stores/DataStore.js
Expand Up @@ -70,7 +70,7 @@ class DataStore {
getOffset(id) {
return new Promise((resolve, reject) => {
if (!id) {
return reject('No file rID');
return reject('No file ID');
}
resolve({ size: 0 });
});
Expand Down
11 changes: 5 additions & 6 deletions test/HeadHandler.js
Expand Up @@ -34,18 +34,17 @@ describe('HeadHandler', () => {
it('should 404 if no file ID ', (done) => {
req.headers = {};
req.url = `${path}/`;
handler.send(req, res);
// This isn't really testing the promise resolution?
handler.send(req, res)
assert.equal(res.statusCode, 404)
done();
});

it('should resolve a promise with the offset', (done) => {
req.headers = {};
req.url = `${path}/1234`;
handler.send(req, res);
// This isn't really testing the promise resolution?
assert.equal(res.statusCode, 200)
done();
handler.send(req, res).then(() => {
assert.equal(hasHeader(res, { 'Upload-Offset': 0 }), true);
assert.equal(res.statusCode, 200);
}).then(done);
});
});

0 comments on commit 2afecab

Please sign in to comment.