This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: integrates new implementation into old test suits
- Loading branch information
1 parent
148d074
commit 4bf7781
Showing
7 changed files
with
67 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const normalize = require('./units/normalize'); | ||
const validateElement = require('./validateElement'); | ||
|
||
function validate(real, expected, type, callback) { | ||
const normalizedReal = normalize(real); | ||
const normalizedExpected = normalize(expected); | ||
|
||
if (type !== 'request' && type !== 'response') { | ||
throw new Error( | ||
`Can't validate: expected transaction "type" to be "request" or "response", but got: ${type}.` | ||
); | ||
} | ||
|
||
const results = validateElement(normalizedReal, normalizedExpected); | ||
|
||
// TODO Propagate the error. | ||
callback(null, { | ||
version: '2', | ||
...results | ||
}); | ||
} | ||
|
||
module.exports = validate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const isset = require('../utils/isset'); | ||
const validateStatusCode = require('./units/validateStatusCode'); | ||
const validateHeaders = require('./units/validateHeaders'); | ||
const { validateBody } = require('./units/validateBody'); | ||
|
||
function validateElement(real, expected) { | ||
const results = {}; | ||
|
||
if (real.statusCode) { | ||
results.statusCode = validateStatusCode(real, expected); | ||
} | ||
|
||
if (real.headers && expected.headers) { | ||
results.headers = validateHeaders(real, expected); | ||
} | ||
|
||
if ( | ||
isset(real.body) && | ||
(isset(expected.body) || isset(expected.bodySchema)) | ||
) { | ||
results.body = validateBody(real, expected); | ||
} | ||
|
||
return results; | ||
} | ||
|
||
module.exports = validateElement; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters