test: move server-test into provision-test
This commit is contained in:
39
src/routes/test/api-test.js
Normal file
39
src/routes/test/api-test.js
Normal file
@@ -0,0 +1,39 @@
|
||||
/* jslint node:true */
|
||||
/* global it:false */
|
||||
/* global describe:false */
|
||||
/* global before:false */
|
||||
/* global after:false */
|
||||
|
||||
'use strict';
|
||||
|
||||
const common = require('./common.js'),
|
||||
expect = require('expect.js'),
|
||||
superagent = require('superagent');
|
||||
|
||||
describe('REST API', function () {
|
||||
const { setup, cleanup, serverUrl, owner } = common;
|
||||
|
||||
before(setup);
|
||||
after(cleanup);
|
||||
|
||||
it('does not crash with invalid JSON', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/users`)
|
||||
.query({ access_token: owner.token })
|
||||
.set('content-type', 'application/json')
|
||||
.send('some invalid non-strict json')
|
||||
.ok(() => true);
|
||||
|
||||
expect(response.statusCode).to.equal(400);
|
||||
expect(response.body.message).to.be('Failed to parse body');
|
||||
});
|
||||
|
||||
it('does not crash with invalid string', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/users`)
|
||||
.query({ access_token: owner.token })
|
||||
.set('content-type', 'application/x-www-form-urlencoded')
|
||||
.send('some string')
|
||||
.ok(() => true);
|
||||
|
||||
expect(response.statusCode).to.equal(400);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user