@@ -20,55 +20,49 @@ const path = require('path');
20
20
const chaiResponseValidator = require ( '../../..' ) ;
21
21
22
22
const pathToApiSpec = path . resolve ( 'test/exampleOpenApiFiles/valid/openapi3.yml' ) ;
23
-
23
+ chai . use ( chaiResponseValidator ( pathToApiSpec ) ) ;
24
24
const { expect } = chai ;
25
25
26
+ describe ( 'Using an OA3 spec that defines server paths' , function ( ) {
27
+ describe ( 'res.req.path matches a defined sever path' , function ( ) {
28
+ const differentServer = '/remote' ;
29
+ const res = {
30
+ status : 200 ,
31
+ req : {
32
+ method : 'GET' ,
33
+ path : `${ differentServer } /test/responseBody/schemaDef` ,
34
+ } ,
35
+ body : 'valid body (string)' ,
36
+ } ;
26
37
27
- describe ( 'Server tests' , function ( ) {
28
- before ( function ( ) {
29
- chai . use ( chaiResponseValidator ( pathToApiSpec ) ) ;
30
- } ) ;
31
- describe ( 'using a different server' , function ( ) {
32
- describe ( 'the server path is defined' , function ( ) {
33
- const differentServer = '/remote' ;
34
- const res = {
35
- status : 200 ,
36
- req : {
37
- method : 'GET' ,
38
- path : `${ differentServer } /test/responseBody/schemaDef` ,
39
- } ,
40
- body : 'valid body (string)' ,
41
- } ;
42
-
43
- it ( 'passes' , function ( ) {
44
- expect ( res ) . to . satisfyApiSpec ;
45
- } ) ;
38
+ it ( 'passes' , function ( ) {
39
+ expect ( res ) . to . satisfyApiSpec ;
40
+ } ) ;
46
41
47
- it ( 'fails when using .not' , function ( ) {
48
- const assertion = ( ) => expect ( res ) . to . not . satisfyApiSpec ;
49
- expect ( assertion ) . to . throw ( '' ) ;
50
- } ) ;
42
+ it ( 'fails when using .not' , function ( ) {
43
+ const assertion = ( ) => expect ( res ) . to . not . satisfyApiSpec ;
44
+ expect ( assertion ) . to . throw ( '' ) ;
51
45
} ) ;
52
- describe ( 'the server path is NOT defined' , function ( ) {
53
- const differentServer = '/missing' ;
54
- const res = {
55
- status : 200 ,
56
- req : {
57
- method : 'GET' ,
58
- path : `${ differentServer } /test/responseBody/schemaDef` ,
59
- } ,
60
- body : 'valid body (string)' ,
61
- } ;
46
+ } ) ;
47
+ describe ( 'res.req.path does not match a defined sever path' , function ( ) {
48
+ const differentServer = '/missing' ;
49
+ const res = {
50
+ status : 200 ,
51
+ req : {
52
+ method : 'GET' ,
53
+ path : `${ differentServer } /test/responseBody/schemaDef` ,
54
+ } ,
55
+ body : 'valid body (string)' ,
56
+ } ;
62
57
63
- it ( 'fails' , function ( ) {
64
- const assertion = ( ) => expect ( res ) . to . satisfyApiSpec ;
65
- expect ( assertion ) . to . throw ( 'No server matching \'/missing/test/responseBody/schemaDef\' path defined in OpenAPI spec' ) ;
66
- } ) ;
58
+ it ( 'fails' , function ( ) {
59
+ const assertion = ( ) => expect ( res ) . to . satisfyApiSpec ;
60
+ expect ( assertion ) . to . throw ( 'No server matching \'/missing/test/responseBody/schemaDef\' path defined in OpenAPI spec' ) ;
61
+ } ) ;
67
62
68
- it ( 'fails when using .not' , function ( ) {
69
- const assertion = ( ) => expect ( res ) . to . not . satisfyApiSpec ;
70
- expect ( assertion ) . to . throw ( 'No server matching \'/missing/test/responseBody/schemaDef\' path defined in OpenAPI spec' ) ;
71
- } ) ;
63
+ it ( 'fails when using .not' , function ( ) {
64
+ const assertion = ( ) => expect ( res ) . to . not . satisfyApiSpec ;
65
+ expect ( assertion ) . to . throw ( 'No server matching \'/missing/test/responseBody/schemaDef\' path defined in OpenAPI spec' ) ;
72
66
} ) ;
73
67
} ) ;
74
- } ) ;
68
+ } ) ;
0 commit comments