-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from line-o/feat/better-media-types
Better media type handling
- Loading branch information
Showing
10 changed files
with
612 additions
and
330 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
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,41 @@ | ||
const util = require('./util.js') | ||
const chai = require('chai') | ||
const expect = chai.expect | ||
|
||
describe('On Login', function () { | ||
let response | ||
|
||
before(async function () { | ||
await util.login() | ||
response = await util.axios.get('api/parameters', {}) | ||
}) | ||
|
||
it('public route can be called', function () { | ||
expect(response.status).to.equal(200); | ||
}) | ||
|
||
it('user property is set on request map', function () { | ||
expect(response.data.user).to.be.a('object') | ||
expect(response.data.user.name).to.equal("admin") | ||
expect(response.data.user.dba).to.equal(true) | ||
}) | ||
|
||
describe('On logout', function () { | ||
let logoutResponse | ||
let guestResponse | ||
before(async function () { | ||
logoutResponse = await util.axios.get('logout') | ||
guestResponse = await util.axios.get('api/parameters', {}) | ||
}) | ||
it('request returns true', function () { | ||
expect(logoutResponse.status).to.equal(200) | ||
expect(logoutResponse.data.success).to.equal(true) | ||
}) | ||
it('public route sets guest as user', function () { | ||
expect(guestResponse.status).to.equal(200) | ||
expect(guestResponse.data.user.name).to.equal("guest") | ||
expect(guestResponse.data.user.dba).to.equal(false) | ||
}) | ||
|
||
}) | ||
}) |
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,41 @@ | ||
const util = require('./util.js') | ||
const chai = require('chai') | ||
const expect = chai.expect | ||
|
||
describe('Error reporting', function() { | ||
it('receives error report', function() { | ||
return util.axios.get('api/errors') | ||
.catch(function(error) { | ||
expect(error.response.status).to.equal(404) | ||
expect(error.response.data.description).to.equal('document not found') | ||
expect(error.response.data.value).to.equal('error details') | ||
}) | ||
}) | ||
|
||
it('receives dynamic XQuery error', function() { | ||
return util.axios.post('api/errors') | ||
.catch(function(error) { | ||
expect(error.response.status).to.equal(500) | ||
expect(error.response.data.line).to.match(/\d+/) | ||
expect(error.response.data.description).to.contain('$undefined') | ||
}) | ||
}) | ||
|
||
it('receives explicit error', function() { | ||
return util.axios.delete('api/errors') | ||
.catch(function(error) { | ||
expect(error.response.status).to.equal(403) | ||
expect(error.response.headers['content-type']).to.equal('application/xml') | ||
expect(error.response.data).to.equal('<forbidden/>') | ||
}) | ||
}) | ||
|
||
it('calls error handler', function() { | ||
return util.axios.get('api/errors/handle') | ||
.catch(function(error) { | ||
expect(error.response.status).to.equal(500) | ||
expect(error.response.headers['content-type']).to.equal('text/html') | ||
expect(error.response.data).to.contain('$undefined') | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.