Skip to content

Commit 0513d14

Browse files
committed
error handling tests
1 parent 311a018 commit 0513d14

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"express": "^4.13.4",
3939
"istanbul": "^0.4.3",
4040
"mocha": "^2.5.3",
41+
"pre-commit": "^1.1.3",
4142
"supertest": "^1.2.0"
4243
}
4344
}

spec/proxy_handler.spec.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,26 @@ describe('jsonscript proxy handler', function() {
204204
});
205205
});
206206

207+
describe('error handling', function() {
208+
it('should return error if script is invalid', function() {
209+
send({
210+
script: {
211+
$exec: 'service1',
212+
$args: {
213+
method: 'get',
214+
path: '/object/1'
215+
},
216+
$wrongProperty: true
217+
}
218+
}, function (err, resp) {
219+
assert(!!err);
220+
assert.equal(resp.statusCode, 400);
221+
assert.equal(resp.body.error, 'script is invalid');
222+
done();
223+
});
224+
});
225+
});
226+
207227
describe('sequential evaluation', function() {
208228
it('should process GET and then POST', function (done) {
209229
send({
@@ -247,6 +267,14 @@ describe('jsonscript proxy handler', function() {
247267

248268

249269
describe('options', function() {
270+
describe('options validation', function() {
271+
it('should throw if options are invalid', function() {
272+
assert.throws(function() {
273+
var proxy = createProxy({}); // "services" is required property
274+
});
275+
});
276+
});
277+
250278
describe('processResponse: "body"', function() {
251279
beforeEach(function() {
252280
proxy = createProxy({ services: SERVICES, processResponse: 'body' });

0 commit comments

Comments
 (0)