Skip to content

Commit 4c09175

Browse files
committed
type checks, tests for #929
1 parent b79c49d commit 4c09175

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

test/durability.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* global after, before, describe, it */
2+
3+
'use strict';
4+
5+
var expect = require('expect');
6+
var test = require('unit.js');
7+
var SwaggerClient = require('..');
8+
9+
var petstoreRaw = require('./spec/v2/petstore.json');
10+
11+
12+
describe('swagger resolver', function () {
13+
it('fails gracefully with bad spec', function(done) {
14+
new SwaggerClient({
15+
spec: 'bad',
16+
usePromise: true
17+
}).then(function(client) {
18+
done('should have failed');
19+
}).catch(function(err) {
20+
done();
21+
})
22+
});
23+
24+
it('fails gracefully with bad URL', function(done) {
25+
new SwaggerClient({
26+
url: 'http://fake.fake/swagger.json',
27+
usePromise: true
28+
}).then(function(client) {
29+
done('should have failed');
30+
}).catch(function(err) {
31+
done();
32+
})
33+
});
34+
35+
it('fails gracefully with operation', function(done) {
36+
new SwaggerClient({
37+
spec: petstoreRaw,
38+
usePromise: true
39+
}).then(function(client) {
40+
client.pet.getPetById({petId: 3})
41+
.then(function(data) {
42+
console.log('ok')
43+
console.log(data);
44+
done('should have failed');
45+
})
46+
.catch(function(error) {
47+
console.log('error')
48+
console.log(error);
49+
done();
50+
})
51+
}).catch(function(err) {
52+
done('should have failed');
53+
})
54+
});
55+
});

0 commit comments

Comments
 (0)