This repository was archived by the owner on Nov 8, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +23
-51
lines changed Expand file tree Collapse file tree 4 files changed +23
-51
lines changed Original file line number Diff line number Diff line change @@ -24,25 +24,19 @@ process.stdin.on('end', function() {
24
24
25
25
var realHttp = curlParser . parseBack ( stdin ) ;
26
26
27
- var realRequest = httpParser . parseRequest ( realHttp [ ' request' ] ) ;
28
- var realResponse = httpParser . parseResponse ( realHttp [ ' response' ] ) ;
27
+ var realRequest = httpParser . parseRequest ( realHttp . request ) ;
28
+ var realResponse = httpParser . parseResponse ( realHttp . response ) ;
29
29
30
- var expectedRequest = httpParser . parseRequest ( expectedHttp [ ' request' ] ) ;
31
- var expectedResponse = httpParser . parseResponse ( expectedHttp [ ' response' ] ) ;
30
+ var expectedRequest = httpParser . parseRequest ( expectedHttp . request ) ;
31
+ var expectedResponse = httpParser . parseResponse ( expectedHttp . response ) ;
32
32
33
33
var requestResult = false ;
34
34
var responseResult = false ;
35
35
36
- gavel . validate ( realRequest , expectedRequest , 'request' , function (
37
- err ,
38
- result
39
- ) {
36
+ gavel . validate ( realRequest , expectedRequest , function ( err , result ) {
40
37
requestResult = result ;
41
38
42
- gavel . validate ( realResponse , expectedResponse , 'response' , function (
43
- err ,
44
- result
45
- ) {
39
+ gavel . validate ( realResponse , expectedResponse , function ( err , result ) {
46
40
responseResult = result ;
47
41
} ) ;
48
42
} ) ;
Original file line number Diff line number Diff line change @@ -5,16 +5,9 @@ const { validateMessage } = require('./validateMessage');
5
5
* a legacy-compliant validation results.
6
6
* @param {Object } real
7
7
* @param {Object } expected
8
- * @param {'request'|'response' } type
9
8
* @param {(error: Error, result: Object) => void } callback
10
9
*/
11
- function validate ( real , expected , type , callback ) {
12
- if ( type !== 'request' && type !== 'response' ) {
13
- throw new Error (
14
- `Can't validate: expected transaction "type" to be "request" or "response", but got: ${ type } .`
15
- ) ;
16
- }
17
-
10
+ function validate ( real , expected , callback ) {
18
11
let results ;
19
12
20
13
try {
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ class World {
109
109
}
110
110
111
111
validate ( callback ) {
112
- return gavel . validate ( this . real , this . expected , 'response' , callback ) ;
112
+ return gavel . validate ( this . real , this . expected , callback ) ;
113
113
}
114
114
115
115
parseHeaders ( headersString ) {
Original file line number Diff line number Diff line change @@ -50,16 +50,11 @@ describe('Gavel proxies to functions with callbacks', () => {
50
50
let error = null ;
51
51
52
52
before ( ( done ) => {
53
- validate (
54
- cloneHttpMessage ,
55
- baseHttpMessage ,
56
- variant ,
57
- ( err , result ) => {
58
- error = err ;
59
- results = result ;
60
- done ( ) ;
61
- }
62
- ) ;
53
+ validate ( cloneHttpMessage , baseHttpMessage , ( err , result ) => {
54
+ error = err ;
55
+ results = result ;
56
+ done ( ) ;
57
+ } ) ;
63
58
} ) ;
64
59
65
60
it ( 'should call the callback without any errors' , ( ) =>
@@ -72,16 +67,11 @@ describe('Gavel proxies to functions with callbacks', () => {
72
67
let error = null ;
73
68
74
69
before ( ( done ) => {
75
- validate (
76
- similarHttpMessage ,
77
- baseHttpMessage ,
78
- variant ,
79
- ( err , result ) => {
80
- error = err ;
81
- results = result ;
82
- done ( ) ;
83
- }
84
- ) ;
70
+ validate ( similarHttpMessage , baseHttpMessage , ( err , result ) => {
71
+ error = err ;
72
+ results = result ;
73
+ done ( ) ;
74
+ } ) ;
85
75
} ) ;
86
76
87
77
it ( 'should call the callback without any errors' , ( ) =>
@@ -94,16 +84,11 @@ describe('Gavel proxies to functions with callbacks', () => {
94
84
let error = null ;
95
85
96
86
before ( ( done ) => {
97
- validate (
98
- differentHttpMessage ,
99
- baseHttpMessage ,
100
- variant ,
101
- ( err , result ) => {
102
- error = err ;
103
- results = result ;
104
- done ( ) ;
105
- }
106
- ) ;
87
+ validate ( differentHttpMessage , baseHttpMessage , ( err , result ) => {
88
+ error = err ;
89
+ results = result ;
90
+ done ( ) ;
91
+ } ) ;
107
92
} ) ;
108
93
109
94
it ( 'should call the callback without any errors' , ( ) =>
You can’t perform that action at this time.
0 commit comments