2021-08-18 20:15:02 +02:00
|
|
|
import { expect } from "chai";
|
2024-05-11 11:16:00 +02:00
|
|
|
import { Github } from "../github";
|
|
|
|
|
import { Schema } from "../schema-tester";
|
|
|
|
|
import { Files } from "../utillity";
|
2021-08-18 20:15:02 +02:00
|
|
|
|
2022-07-13 21:15:38 +02:00
|
|
|
describe("test incorrect files", function () {
|
2021-08-18 20:48:09 +02:00
|
|
|
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);
|
|
|
|
|
|
2022-06-13 23:36:37 +02:00
|
|
|
files
|
|
|
|
|
.filter((f) => f.endsWith(".json"))
|
|
|
|
|
.forEach((file) => {
|
2021-08-18 20:48:09 +02:00
|
|
|
const testfolder = file.replace(folder + "/", "");
|
2021-08-18 20:15:02 +02:00
|
|
|
|
2022-10-06 21:32:49 +02:00
|
|
|
it(`File should invalidate & have a schema: ${testfolder}`, async function () {
|
2021-10-04 12:08:55 +02:00
|
|
|
const result = validator.ValidateFile(file);
|
|
|
|
|
const schemas = validator.ls.getMatchingSchemas(result.doc, result.jdoc);
|
|
|
|
|
|
2022-10-06 21:32:49 +02:00
|
|
|
result.promise.then(
|
|
|
|
|
(succes) => {
|
|
|
|
|
expect(succes.length, "Expected errors! but had none").to.greaterThan(0);
|
|
|
|
|
},
|
|
|
|
|
(fail) => {
|
|
|
|
|
Github.createError("No errors where found", { file: file });
|
|
|
|
|
expect.fail("Failed to validate");
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
schemas.then(
|
|
|
|
|
(success) => {
|
|
|
|
|
expect(success.length, "Expected schemas to be returned").to.greaterThan(0);
|
|
|
|
|
},
|
|
|
|
|
(fail) => {
|
|
|
|
|
Github.createError("Found no schema", { file: file });
|
|
|
|
|
expect.fail("failed on retrieving schemas");
|
|
|
|
|
}
|
|
|
|
|
);
|
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
|
|
|
});
|
2022-06-13 23:36:37 +02:00
|
|
|
});
|
2021-08-18 20:15:02 +02:00
|
|
|
});
|