Refactor uploads

This commit is contained in:
Jonathan Cremin 2016-05-25 21:03:07 +01:00
parent 75a46212da
commit f59b9a5d22
14 changed files with 297 additions and 269 deletions

View file

@ -1,3 +1,4 @@
import path from 'path';
import assert from 'assert';
import { agent } from 'supertest';
import app from '../../app';
@ -25,11 +26,11 @@ describe('hostr-api file', function file() {
this.timeout(30000);
request
.post('/api/file')
.attach('file', './test/fixtures/utah-arches.jpg')
.attach('file', path.join(__dirname, '..', 'fixtures', 'tall.jpg'))
.auth('test@hostr.co', 'test-password')
.expect(201)
.expect((response) => {
assert(response.body.name === 'utah-arches.jpg');
assert(response.body.name === 'tall.jpg');
id = response.body.id;
})
.end(done);
@ -42,7 +43,7 @@ describe('hostr-api file', function file() {
.get('/api/file/' + id)
.expect(200)
.expect((response) => {
assert(response.body.name === 'utah-arches.jpg');
assert(response.body.name === 'tall.jpg');
})
.end(done);
});