Skip to content

Commit 71ad3c8

Browse files
timbertsonTim Emiola
authored andcommitted
add test for multiple response errorsg
1 parent 59573c6 commit 71ad3c8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/test.transporters.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,32 @@ describe('Transporters', function() {
4141
var re = new RegExp(applicationName + ' ' + defaultUserAgentRE);
4242
assert(re.test(opts.headers['User-Agent']));
4343
});
44+
45+
it('should create a single error from multiple response errors', function(done) {
46+
var firstError = {
47+
message: 'Error 1',
48+
code: 'ERR1',
49+
};
50+
var secondError = {
51+
message: 'Error 2',
52+
code: 'ERR2',
53+
};
54+
nock('http://example.com')
55+
.get('/api')
56+
.reply(200, {
57+
error: {
58+
errors: [ firstError, secondError ]
59+
}
60+
});
61+
62+
transporter.request({
63+
uri: 'http://example.com/api',
64+
}, function(error) {
65+
assert(error.message === 'Error 1\nError 2');
66+
assert(error.code, 'ERR1');
67+
assert(error.errors.length, 2);
68+
assert(error.errors[1].code, 'ERR2');
69+
done();
70+
});
71+
});
4472
});

0 commit comments

Comments
 (0)