-
-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/*eslint no-unused-expressions: 0, prefer-arrow-callback: 0, no-console:0 */ | ||
|
||
/* globals before: false, after: false */ | ||
|
||
'use strict'; | ||
|
||
const supertest = require('supertest'); | ||
const chai = require('chai'); | ||
|
||
const expect = chai.expect; | ||
chai.config.includeStack = true; | ||
const config = require('wild-config'); | ||
|
||
const server = supertest.agent(`http://127.0.0.1:${config.api.port}`); | ||
|
||
describe('Storage tests', function () { | ||
this.timeout(10000); // eslint-disable-line no-invalid-this | ||
|
||
let user; | ||
|
||
before(async () => { | ||
// ensure that we have an existing user account | ||
const response = await server | ||
.post('/users') | ||
.send({ | ||
username: 'storageuser', | ||
password: 'secretvalue', | ||
address: '[email protected]', | ||
name: 'storage user' | ||
}) | ||
.expect(200); | ||
expect(response.body.success).to.be.true; | ||
expect(response.body.id).to.exist; | ||
|
||
user = response.body.id; | ||
}); | ||
|
||
after(async () => { | ||
if (!user) { | ||
return; | ||
} | ||
|
||
const response = await server.delete(`/users/${user}`).expect(200); | ||
expect(response.body.success).to.be.true; | ||
|
||
user = false; | ||
}); | ||
|
||
it('should POST /users/{user}/storage', async () => { | ||
const response = await server | ||
.post(`/users/${user}/storage`) | ||
.send({ | ||
filename: 'image.gif', | ||
contentType: 'image/gif', | ||
encoding: 'base64', | ||
content: | ||
'R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7' | ||
}) | ||
.expect(200); | ||
expect(response.body.success).to.be.true; | ||
}); | ||
}); |