File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments