agreed-client
Advanced tools
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
module.exports = (agrees, filter) => { | ||
@@ -2,0 +4,0 @@ var result = agrees; |
@@ -0,3 +1,20 @@ | ||
'use strict'; | ||
const colo = require('colo'); | ||
module.exports = function reason(diff, depth) { | ||
const isEmpty = require('is-empty'); | ||
module.exports.schemaErrors = (errors) => { | ||
if (isEmpty(errors)) { | ||
return; | ||
} | ||
if (Array.isArray(errors)) { | ||
errors.forEach((error) => { | ||
console.log(`${colo.bold('schema errors are found.')}`); | ||
console.log(error.stack); | ||
}); | ||
} | ||
}; | ||
module.exports.diff = function reason(diff, depth) { | ||
if (depth == null) { | ||
@@ -4,0 +21,0 @@ depth = 0; |
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
const isEmpty = require('is-empty'); | ||
@@ -5,14 +7,17 @@ const colo = require('colo'); | ||
module.exports = (agrees, opts) => (diffs) => { | ||
return diffs.map((diff, i) => { | ||
module.exports = (agrees, opts) => (results) => { | ||
return results.map((result, i) => { | ||
const agree = agrees[i]; | ||
const diff = result.diff; | ||
const schemaErrors = result.schemaErrors; | ||
const url = `${opts.scheme}://${opts.host}:${opts.port}${agree.request.path}`; | ||
if (isEmpty(diff)) { | ||
if (isEmpty(diff) && isEmpty(schemaErrors)) { | ||
console.log(`${colo.bold.green('✔ pass!')} ${agree.request.method} ${url}`); | ||
} else { | ||
console.log(`${colo.bold.red('✗ fail!')} ${agree.request.method} ${url}`); | ||
reason(diff); | ||
reason.diff(diff); | ||
reason.schemaErrors(schemaErrors); | ||
} | ||
}); | ||
}; |
{ | ||
"name": "agreed-client", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "agreed client, testing utilities", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
agreed-client | ||
=================== | ||
[](https://travis-ci.org/recruit-tech/agreed-client) | ||
@@ -4,0 +5,0 @@ An agreed client for check response. |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
const client = require('../index'); | ||
@@ -2,0 +3,0 @@ const server = require('agreed-server'); |
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
const reason = require(`${process.cwd()}/lib/reason`); | ||
@@ -17,3 +19,3 @@ const test = require('eater/runner').test; | ||
reason(diff); | ||
reason.diff(diff); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
6671
28.54%12
9.09%148
15.63%27
3.85%