@@ -62,7 +62,7 @@ function isJsonContentType(contentType) {
62
62
* on the given body and normalized headers.
63
63
* @param {string } body
64
64
* @param {string } contentType
65
- * @param {'real '|'expected' } httpMessageOrigin
65
+ * @param {'actual '|'expected' } httpMessageOrigin
66
66
* @returns {[string, MediaType] }
67
67
*/
68
68
function getBodyType ( body , contentType , httpMessageOrigin ) {
@@ -116,14 +116,14 @@ ${error.message}\
116
116
117
117
/**
118
118
* Returns a body validator class based on the given
119
- * real and expected body media types.
120
- * @param {MediaType } realType
119
+ * actual and expected body media types.
121
120
* @param {MediaType } expectedType
121
+ * @param {MediaType } actualType
122
122
* @returns {Validator }
123
123
*/
124
- function getBodyValidator ( realType , expectedType ) {
125
- const both = ( predicate ) => ( real , expected ) => {
126
- return [ real , expected ] . every ( predicate ) ;
124
+ function getBodyValidator ( expectedType , actualType ) {
125
+ const both = ( predicate ) => ( expected , actual ) => {
126
+ return [ expected , actual ] . every ( predicate ) ;
127
127
} ;
128
128
129
129
const validators = [
@@ -132,21 +132,21 @@ function getBodyValidator(realType, expectedType) {
132
132
// would resolve on "application/schema+json" media type too.
133
133
[
134
134
JsonSchema ,
135
- ( real , expected ) => {
136
- return isJson ( real ) && isJsonSchema ( expected ) ;
135
+ ( expected , actual ) => {
136
+ return isJson ( actual ) && isJsonSchema ( expected ) ;
137
137
} ,
138
138
'json'
139
139
] ,
140
140
[ JsonExample , both ( isJson ) , 'json' ]
141
141
] ;
142
142
143
143
const validator = validators . find ( ( [ _name , predicate ] ) => {
144
- return predicate ( realType , expectedType ) ;
144
+ return predicate ( expectedType , actualType ) ;
145
145
} ) ;
146
146
147
147
if ( ! validator ) {
148
148
const error = `Can't validate actual media type '${ mediaTyper . format (
149
- realType
149
+ actualType
150
150
) } ' against the expected media type '${ mediaTyper . format ( expectedType ) } '.`;
151
151
return [ error , null , null ] ;
152
152
}
@@ -157,7 +157,7 @@ function getBodyValidator(realType, expectedType) {
157
157
/**
158
158
* Validates given bodies of transaction elements.
159
159
* @param {Object<string, any> } expected
160
- * @param {Object<string, any> } real
160
+ * @param {Object<string, any> } actual
161
161
*/
162
162
function validateBody ( expected , actual ) {
163
163
const values = {
@@ -171,20 +171,20 @@ function validateBody(expected, actual) {
171
171
}
172
172
173
173
const errors = [ ] ;
174
- const realBodyType = typeof actual . body ;
175
- const hasEmptyRealBody = actual . body === '' ;
174
+ const actualBodyType = typeof actual . body ;
175
+ const hasEmptyActualBody = actual . body === '' ;
176
176
177
- // Throw when user input for real body is not a string.
178
- if ( realBodyType !== 'string' ) {
177
+ // Throw when user input for actual body is not a string.
178
+ if ( actualBodyType !== 'string' ) {
179
179
throw new Error (
180
- `Expected HTTP body to be a string, but got: ${ realBodyType } `
180
+ `Expected HTTP body to be a string, but got: ${ actualBodyType } `
181
181
) ;
182
182
}
183
183
184
- const [ realTypeError , realType ] = getBodyType (
184
+ const [ actualTypeError , actualType ] = getBodyType (
185
185
actual . body ,
186
186
actual . headers && actual . headers [ 'content-type' ] ,
187
- 'real '
187
+ 'actual '
188
188
) ;
189
189
190
190
const [ expectedTypeError , expectedType ] = expected . bodySchema
@@ -195,9 +195,9 @@ function validateBody(expected, actual) {
195
195
'expected'
196
196
) ;
197
197
198
- if ( realTypeError ) {
198
+ if ( actualTypeError ) {
199
199
errors . push ( {
200
- message : realTypeError
200
+ message : actualTypeError
201
201
} ) ;
202
202
}
203
203
@@ -210,18 +210,18 @@ function validateBody(expected, actual) {
210
210
const hasErrors = errors . length > 0 ;
211
211
212
212
// Skipping body validation in case errors during
213
- // real /expected body type definition.
213
+ // actual /expected body type definition.
214
214
const [ validatorError , ValidatorClass , kind ] = hasErrors
215
215
? [ null , null , null ]
216
- : getBodyValidator ( realType , expectedType ) ;
216
+ : getBodyValidator ( expectedType , actualType ) ;
217
217
218
218
if ( validatorError ) {
219
- // In case determined media types mismtach, check if the real is not missing.
219
+ // In case determined media types mismtach, check if the actual is not missing.
220
220
// Keep in mind the following scenarios:
221
221
// 1. Expected '', and got '' (TextDiff/TextDiff, valid)
222
- // 2. Expected {...}, but got '' (Json/TextDiff, invalid, produces "missing real body" error)
222
+ // 2. Expected {...}, but got '' (Json/TextDiff, invalid, produces "missing actual body" error)
223
223
// 3. Expected {...}, but got "foo" (Json/TextDiff, invalid, produces types mismatch error).
224
- if ( expected . body !== '' && hasEmptyRealBody ) {
224
+ if ( expected . body !== '' && hasEmptyActualBody ) {
225
225
errors . push ( {
226
226
message : `Expected "body" of "${ mediaTyper . format (
227
227
expectedType
0 commit comments