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-08-18 20:48:09 +02:00
|
|
|
it(testfolder, () => {
|
2021-08-18 20:15:02 +02:00
|
|
|
let result = validator.ValidateFile(file);
|
|
|
|
|
|
|
|
|
|
result.promise.then(
|
|
|
|
|
(succes) => {
|
2021-08-18 20:48:09 +02:00
|
|
|
expect(succes.length, "Expected errors! but had none").to.greaterThan(0);
|
2021-08-18 20:15:02 +02:00
|
|
|
},
|
|
|
|
|
(fail) => {
|
|
|
|
|
expect.fail("Failed to validate");
|
|
|
|
|
}
|
|
|
|
|
);
|
2021-08-18 20:48:09 +02:00
|
|
|
|
|
|
|
|
return result.promise;
|
2021-08-18 20:15:02 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|