Skip to content

Commit 0cc7fbf

Browse files
committed
added tests for #820
1 parent 8cd6342 commit 0cc7fbf

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

test/client.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,4 +1692,33 @@ describe('SwaggerClient', function () {
16921692
done(exception);
16931693
});
16941694
})
1695+
1696+
it('verifies a 201 response #820', function(done) {
1697+
new SwaggerClient({
1698+
spec: petstoreRaw,
1699+
usePromise: true
1700+
}).then(function (client) {
1701+
return client.pet.getPetById({petId: 777})
1702+
}).then(function (data) {
1703+
expect(data.status).toBe(201);
1704+
done();
1705+
}).catch(function(err) {
1706+
done('oops');
1707+
})
1708+
});
1709+
1710+
it('verifies a 400 response #820', function(done) {
1711+
new SwaggerClient({
1712+
spec: petstoreRaw,
1713+
usePromise: true
1714+
}).then(function (client) {
1715+
return client.pet.getPetById({petId: 666})
1716+
}).then(function (data) {
1717+
done('expected an error');
1718+
}).catch(function(err) {
1719+
expect(err.status).toBe(400);
1720+
expect(err.obj).toEqual({code: 400, message: 'sorry!', type: 'bad input'});
1721+
done();
1722+
})
1723+
});
16951724
});

test/mock.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ exports.petstore = function (arg1, arg2, arg3, arg4) {
4242

4343
res.end();
4444
}
45+
else if (filename === 'test/spec/v2/api/pet/777') {
46+
res.writeHead(201);
47+
res.end();
48+
}
4549
else if (filename === 'test/spec/api/redirect') {
4650
res.writeHead(302, {
4751
'Location': 'http://localhost:8000/api/pet/1'

0 commit comments

Comments
 (0)