mirror of
https://github.com/ColonelParrot/jscanify.git
synced 2025-12-30 22:31:52 +00:00
fix skipped tests with before()
This commit is contained in:
parent
b4e68b12c9
commit
58b26c34c7
@ -39,21 +39,30 @@ function setup() {
|
||||
})
|
||||
}
|
||||
|
||||
let scanner;
|
||||
let cv;
|
||||
|
||||
before(function (done) {
|
||||
console.log("=== beginning tests ===");
|
||||
console.log("loading OpenCV.js...");
|
||||
|
||||
const scanner = new jscanify();
|
||||
scanner.loadOpenCV(function (cv) {
|
||||
scanner = new jscanify();
|
||||
scanner.loadOpenCV(function (loadedCv) {
|
||||
cv = loadedCv;
|
||||
|
||||
console.log("Finished loading OpenCV.js");
|
||||
console.log("Writing test images to: " + OUTPUT_FOLDER);
|
||||
setup()
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* tests an individual image
|
||||
*/
|
||||
function test(testImage, imageCount) {
|
||||
describe("image #" + imageCount, function () {
|
||||
it("should highlight paper", function (done) {
|
||||
it("should highlight paper", function () {
|
||||
const highlighted = scanner.highlightPaper(testImage);
|
||||
const higlightedOutputPath = OUTPUT_FOLDER + "highlighted-" + imageCount + ".jpg";
|
||||
writeFileSync(
|
||||
@ -62,10 +71,9 @@ scanner.loadOpenCV(function (cv) {
|
||||
);
|
||||
|
||||
assert.ok(existsSync(higlightedOutputPath));
|
||||
done();
|
||||
});
|
||||
|
||||
it("should extract paper", function (done) {
|
||||
it("should extract paper", function () {
|
||||
const extracted = scanner.extractPaper(testImage, 386, 500);
|
||||
const extractedOutputPath = OUTPUT_FOLDER + "extracted-" + imageCount + ".jpg";
|
||||
|
||||
@ -75,10 +83,9 @@ scanner.loadOpenCV(function (cv) {
|
||||
);
|
||||
|
||||
assert.ok(existsSync(extractedOutputPath));
|
||||
done();
|
||||
});
|
||||
|
||||
it("should label corner points", function (done) {
|
||||
it("should label corner points", function () {
|
||||
const parsedImage = cv.imread(testImage);
|
||||
const paperContour = scanner.findPaperContour(parsedImage);
|
||||
const {
|
||||
@ -111,13 +118,10 @@ scanner.loadOpenCV(function (cv) {
|
||||
writeFileSync(cornerPointsOutputPath, canvas.toBuffer("image/jpeg"));
|
||||
|
||||
assert.ok(existsSync(cornerPointsOutputPath));
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
setup();
|
||||
|
||||
let imageCount = 1;
|
||||
|
||||
/*
|
||||
@ -134,4 +138,3 @@ scanner.loadOpenCV(function (cv) {
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user