2021-08-18 20:15:02 +02:00
|
|
|
import { expect } from "chai";
|
|
|
|
|
import { Schema } from "../SchemaTester";
|
|
|
|
|
import { Files } from "../Utillity";
|
|
|
|
|
|
2021-08-18 20:48:09 +02:00
|
|
|
describe("test incorrect files", () => {
|
|
|
|
|
const folder = Files.InCorrectFilesFolder().replace(/\\/gi, "/");
|
2021-08-18 20:15:02 +02:00
|
|
|
const files = Files.GetFiles(folder);
|
|
|
|
|
const validator = Schema.GetValidator();
|
|
|
|
|
|
2021-08-18 20:48:09 +02:00
|
|
|
expect(files.length, "No files were returned").to.greaterThan(0);
|
|
|
|
|
|
2021-08-18 20:15:02 +02:00
|
|
|
files.forEach((file) => {
|
|
|
|
|
if (file.endsWith(".json")) {
|
2021-08-18 20:48:09 +02:00
|
|
|
const testfolder = file.replace(folder + "/", "");
|
2021-08-18 20:15:02 +02:00
|
|
|
|
2021-10-04 12:08:55 +02:00
|
|
|
describe(testfolder, () => {
|
|
|
|
|
const result = validator.ValidateFile(file);
|
|
|
|
|
const schemas = validator.ls.getMatchingSchemas(result.doc, result.jdoc);
|
|
|
|
|
|
|
|
|
|
it("schemas", () => {
|
|
|
|
|
return schemas.then(
|
|
|
|
|
(success) => {
|
|
|
|
|
expect(success.length, "Expected schemas to be returned").to.greaterThan(0);
|
|
|
|
|
},
|
|
|
|
|
(fail) => {
|
|
|
|
|
expect.fail("failed on retrieving schemas");
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("validation", () => {
|
|
|
|
|
result.promise.then(
|
|
|
|
|
(succes) => {
|
|
|
|
|
expect(succes.length, "Expected errors! but had none").to.greaterThan(0);
|
|
|
|
|
},
|
|
|
|
|
(fail) => {
|
|
|
|
|
expect.fail("Failed to validate");
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return result.promise;
|
|
|
|
|
});
|
2021-08-18 20:48:09 +02:00
|
|
|
|
2021-08-18 20:52:07 +02:00
|
|
|
return Promise.all([schemas, result]);
|
2021-08-18 20:15:02 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|