Skip to content

Commit 6bc5ccb

Browse files
author
Richard Waller
authored
Make tests easier to read (#210)
1 parent 9e1a3e6 commit 6bc5ccb

File tree

25 files changed

+237
-277
lines changed

25 files changed

+237
-277
lines changed

commonTestResources/exampleApp.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,25 @@ const express = require('express'); // eslint-disable-line import/no-extraneous-
22

33
const app = express();
44

5-
app.get('/test/header/application/json/and/responseBody/string', (req, res) =>
5+
app.get('/header/application/json/and/responseBody/string', (req, res) =>
66
res.json('res.body is a string'),
77
);
88

9-
app.get(
10-
'/test/header/application/json/and/responseBody/emptyObject',
11-
(req, res) => res.send({}),
9+
app.get('/header/application/json/and/responseBody/emptyObject', (req, res) =>
10+
res.send({}),
1211
);
1312

14-
app.get('/test/header/application/json/and/responseBody/boolean', (req, res) =>
13+
app.get('/header/application/json/and/responseBody/boolean', (req, res) =>
1514
res.json(false),
1615
);
1716

18-
app.get('/test/header/application/json/and/responseBody/nullable', (req, res) =>
17+
app.get('/header/application/json/and/responseBody/nullable', (req, res) =>
1918
res.json(null),
2019
);
2120

22-
app.get('/test/header/text/html', (req, res) =>
23-
res.send('res.body is a string'),
24-
);
21+
app.get('/header/text/html', (req, res) => res.send('res.body is a string'));
2522

26-
app.get('/test/no/content-type/header/and/no/response/body', (req, res) =>
23+
app.get('/no/content-type/header/and/no/response/body', (req, res) =>
2724
res.sendStatus(204),
2825
);
2926

commonTestResources/exampleOpenApiFiles/valid/basePathDefinedDifferently/basePathProperty.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
swagger: '2.0'
22
info:
3-
description: Has one path.
3+
description: Has one path
44
title: Example OpenApi 2 spec with basePath
55
version: 0.1.0
6-
basePath: /test
6+
basePath: /basePath
77
paths:
8-
/responseBody/string:
8+
/endpointPath:
99
get:
1010
responses:
1111
200:

commonTestResources/exampleOpenApiFiles/valid/basePathDefinedDifferently/noBasePathProperty.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
swagger: '2.0'
22
info:
3-
description: Has one path.
3+
description: Has one path
44
title: Example OpenApi 2 spec with no basePath
55
version: 0.1.0
66
paths:
7-
/test/responseBody/string:
7+
/endpointPath:
88
get:
99
responses:
1010
200:

commonTestResources/exampleOpenApiFiles/valid/openapi2.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"version": "0.1.0"
77
},
88
"paths": {
9-
"/test/responseBody/string": {
9+
"/responseBody/string": {
1010
"get": {
1111
"produces": ["application/json"],
1212
"parameters": [],
@@ -20,7 +20,7 @@
2020
}
2121
}
2222
},
23-
"/test/responseBody/boolean": {
23+
"/responseBody/boolean": {
2424
"get": {
2525
"produces": ["application/json"],
2626
"parameters": [],
@@ -34,7 +34,7 @@
3434
}
3535
}
3636
},
37-
"/test/HTTPMethod": {
37+
"/HTTPMethod": {
3838
"get": {
3939
"parameters": [],
4040
"responses": {
@@ -52,7 +52,7 @@
5252
}
5353
}
5454
},
55-
"/test/multiplePathParams/{param1}/{param2}": {
55+
"/multiplePathParams/{param1}/{param2}": {
5656
"get": {
5757
"parameters": [
5858
{
@@ -75,7 +75,7 @@
7575
}
7676
}
7777
},
78-
"/test/multipleResponsesDefined": {
78+
"/multipleResponsesDefined": {
7979
"get": {
8080
"produces": ["application/json"],
8181
"parameters": [],
@@ -98,7 +98,7 @@
9898
}
9999
}
100100
},
101-
"/test/pathAndQueryParams/{examplePathParam}": {
101+
"/pathAndQueryParams/{examplePathParam}": {
102102
"get": {
103103
"parameters": [
104104
{
@@ -115,7 +115,7 @@
115115
}
116116
}
117117
},
118-
"/test/pathParams/{exampleParam}": {
118+
"/pathParams/{exampleParam}": {
119119
"get": {
120120
"parameters": [
121121
{
@@ -132,7 +132,7 @@
132132
}
133133
}
134134
},
135-
"/test/queryParams": {
135+
"/queryParams": {
136136
"get": {
137137
"parameters": [],
138138
"responses": {
@@ -142,7 +142,7 @@
142142
}
143143
}
144144
},
145-
"/test/responseBody/empty": {
145+
"/responseBody/empty": {
146146
"get": {
147147
"parameters": [],
148148
"responses": {
@@ -152,7 +152,7 @@
152152
}
153153
}
154154
},
155-
"/test/responseBody/emptyObject": {
155+
"/responseBody/emptyObject": {
156156
"get": {
157157
"produces": ["application/json"],
158158
"parameters": [],
@@ -166,7 +166,7 @@
166166
}
167167
}
168168
},
169-
"/test/responseBody/referencesSchemaObject/simple": {
169+
"/responseBody/referencesSchemaObject/simple": {
170170
"get": {
171171
"produces": ["application/json"],
172172
"parameters": [],
@@ -180,7 +180,7 @@
180180
}
181181
}
182182
},
183-
"/test/responseBody/object/depthOver2": {
183+
"/responseBody/object/depthOver2": {
184184
"get": {
185185
"produces": ["application/json"],
186186
"parameters": [],
@@ -212,7 +212,7 @@
212212
}
213213
}
214214
},
215-
"/test/responseBody/object/withMultipleProperties": {
215+
"/responseBody/object/withMultipleProperties": {
216216
"get": {
217217
"produces": ["application/json"],
218218
"parameters": [],
@@ -235,7 +235,7 @@
235235
}
236236
}
237237
},
238-
"/test/responseStatus": {
238+
"/responseStatus": {
239239
"get": {
240240
"parameters": [],
241241
"responses": {
@@ -248,7 +248,7 @@
248248
}
249249
}
250250
},
251-
"/test/responseReferencesResponseDefinitionObject": {
251+
"/responseReferencesResponseDefinitionObject": {
252252
"get": {
253253
"produces": ["application/json"],
254254
"parameters": [],

commonTestResources/exampleOpenApiFiles/valid/openapi3.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ info:
44
description: Has various paths with responses to use in testing
55
version: 0.1.0
66
paths:
7-
/test/responseBody/string:
7+
/responseBody/string:
88
get:
99
responses:
1010
200:
@@ -13,7 +13,7 @@ paths:
1313
application/json:
1414
schema:
1515
type: string
16-
/test/responseBody/boolean:
16+
/responseBody/boolean:
1717
get:
1818
responses:
1919
200:
@@ -22,7 +22,7 @@ paths:
2222
application/json:
2323
schema:
2424
type: boolean
25-
/test/responseBody/object/depthOver2:
25+
/responseBody/object/depthOver2:
2626
get:
2727
responses:
2828
200:
@@ -46,7 +46,7 @@ paths:
4646
properties:
4747
c:
4848
type: string
49-
/test/responseBody/object/withMultipleProperties:
49+
/responseBody/object/withMultipleProperties:
5050
get:
5151
responses:
5252
200:
@@ -63,7 +63,7 @@ paths:
6363
type: string
6464
property2:
6565
type: string
66-
/test/responseBody/referencesSchemaObject/simple:
66+
/responseBody/referencesSchemaObject/simple:
6767
get:
6868
responses:
6969
200:
@@ -72,17 +72,17 @@ paths:
7272
application/json:
7373
schema:
7474
$ref: '#/components/schemas/StringSchema'
75-
/test/responseBody/empty:
75+
/responseBody/empty:
7676
get:
7777
responses:
7878
204:
7979
description: No response body
80-
/test/responseReferencesResponseDefinitionObject:
80+
/responseReferencesResponseDefinitionObject:
8181
get:
8282
responses:
8383
200:
8484
$ref: '#/components/responses/SimpleResponseDefinitionObject'
85-
/test/multipleResponsesDefined:
85+
/multipleResponsesDefined:
8686
get:
8787
responses:
8888
201:
@@ -99,12 +99,12 @@ paths:
9999
type: integer
100100
203:
101101
description: No response body
102-
/test/queryParams:
102+
/queryParams:
103103
get:
104104
responses:
105105
204:
106106
description: No response body
107-
/test/pathParams/{exampleParam}:
107+
/pathParams/{exampleParam}:
108108
get:
109109
parameters:
110110
- in: path
@@ -115,7 +115,7 @@ paths:
115115
responses:
116116
204:
117117
description: No response body
118-
/test/multiplePathParams/{param1}/{param2}:
118+
/multiplePathParams/{param1}/{param2}:
119119
get:
120120
parameters:
121121
- in: path
@@ -131,7 +131,7 @@ paths:
131131
responses:
132132
204:
133133
description: No response body
134-
/test/pathAndQueryParams/{examplePathParam}:
134+
/pathAndQueryParams/{examplePathParam}:
135135
get:
136136
parameters:
137137
- in: path
@@ -142,14 +142,14 @@ paths:
142142
responses:
143143
204:
144144
description: No response body
145-
/test/responseStatus:
145+
/responseStatus:
146146
get:
147147
responses:
148148
200:
149149
description: No response body
150150
204:
151151
description: No response body
152-
/test/HTTPMethod:
152+
/HTTPMethod:
153153
get:
154154
responses:
155155
204:
@@ -158,7 +158,7 @@ paths:
158158
responses:
159159
204:
160160
description: No response body
161-
/test/header/application/json/and/responseBody/string:
161+
/header/application/json/and/responseBody/string:
162162
get:
163163
responses:
164164
200:
@@ -167,7 +167,7 @@ paths:
167167
application/json:
168168
schema:
169169
type: string
170-
/test/header/application/json/and/responseBody/emptyObject:
170+
/header/application/json/and/responseBody/emptyObject:
171171
get:
172172
responses:
173173
200:
@@ -176,7 +176,7 @@ paths:
176176
application/json:
177177
schema:
178178
type: object
179-
/test/header/application/json/and/responseBody/boolean:
179+
/header/application/json/and/responseBody/boolean:
180180
get:
181181
responses:
182182
200:
@@ -185,7 +185,7 @@ paths:
185185
application/json:
186186
schema:
187187
type: boolean
188-
/test/header/application/json/and/responseBody/nullable:
188+
/header/application/json/and/responseBody/nullable:
189189
get:
190190
responses:
191191
200:
@@ -195,7 +195,7 @@ paths:
195195
schema:
196196
type: object
197197
nullable: true
198-
/test/header/text/html:
198+
/header/text/html:
199199
get:
200200
responses:
201201
200:
@@ -204,7 +204,7 @@ paths:
204204
text/html:
205205
schema:
206206
type: string
207-
/test/no/content-type/header/and/no/response/body:
207+
/no/content-type/header/and/no/response/body:
208208
get:
209209
responses:
210210
204:

commonTestResources/exampleOpenApiFiles/valid/preferNonTemplatedPathOverTemplatedPath/nonTemplatedPathAfterTemplatedPath/openapi2.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ info:
44
description: Test that our plugins prefer to match responses to non-templated paths over templated paths
55
version: 0.1.0
66
paths:
7-
/test/preferNonTemplatedPathOverTemplatedPath/{templatedPath}:
7+
/preferNonTemplatedPathOverTemplatedPath/{templatedPath}:
88
get:
99
responses:
1010
200:
1111
description: Response body should be a number
1212
schema:
1313
type: number
14-
/test/preferNonTemplatedPathOverTemplatedPath/nonTemplatedPath:
14+
/preferNonTemplatedPathOverTemplatedPath/nonTemplatedPath:
1515
get:
1616
responses:
1717
200:

0 commit comments

Comments
 (0)