@buggyorg/checker
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -6,4 +6,5 @@ 'use strict'; | ||
}); | ||
exports.errors = errors; | ||
exports.check = check; | ||
function check(graph) { | ||
function errors(graph) { | ||
var edges = graph.edges(); | ||
@@ -29,2 +30,11 @@ var nodes = graph.nodes(); | ||
return errorList; | ||
} | ||
function check(graph) { | ||
var errs = errors(graph); | ||
if (errs.length === 0) { | ||
return graph; | ||
} else { | ||
throw new Error('Found problems while checking graph\n ' + JSON.stringify(errs, null, 2)); | ||
} | ||
} |
{ | ||
"name": "@buggyorg/checker", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A buggy graph consistency checker.", | ||
@@ -5,0 +5,0 @@ "main": "lib/api.js", |
@@ -1,2 +0,2 @@ | ||
export function check (graph) { | ||
export function errors (graph) { | ||
var edges = graph.edges() | ||
@@ -23,1 +23,10 @@ var nodes = graph.nodes() | ||
} | ||
export function check (graph) { | ||
var errs = errors(graph) | ||
if (errs.length === 0) { | ||
return graph | ||
} else { | ||
throw new Error(`Found problems while checking graph\n ${JSON.stringify(errs, null, 2)}`) | ||
} | ||
} |
@@ -14,3 +14,3 @@ /* global describe, it */ | ||
it('Find errors in the graph', function () { | ||
var d = checker.check(graph) | ||
var d = checker.errors(graph) | ||
expect(d).to.have.length(3) | ||
@@ -23,7 +23,17 @@ d = _.flatten(d) | ||
it('throws an exception if an error occurs while checking', () => { | ||
expect(() => checker.check(graph)).to.throw(Error) | ||
}) | ||
it('returns an empty array if no errors occur', () => { | ||
var g = grlib.json.read(JSON.parse(fs.readFileSync('./test/fixtures/inc.json'))) | ||
var res = checker.check(g) | ||
var res = checker.errors(g) | ||
expect(res).to.have.length(0) | ||
}) | ||
it('returns the same graph if no error occurs', () => { | ||
var g = grlib.json.read(JSON.parse(fs.readFileSync('./test/fixtures/inc.json'))) | ||
var newG = checker.check(g) | ||
expect(grlib.json.write(newG)).to.deep.equal(grlib.json.write(g)) | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76368
179