Files
minecraft-bedrock-json-schemas/test/src/files/incorrect.test.ts

49 lines
1.4 KiB
TypeScript
Raw Normal View History

2021-08-18 20:15:02 +02:00
import { expect } from "chai";
import { Schema } from "../SchemaTester";
import { Files } from "../Utillity";
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-07-13 21:15:38 +02:00
describe(testfolder, function () {
2021-10-04 12:08:55 +02:00
const result = validator.ValidateFile(file);
const schemas = validator.ls.getMatchingSchemas(result.doc, result.jdoc);
2022-07-13 21:15:38 +02:00
it("schemas", function () {
2021-10-04 12:08:55 +02:00
return schemas.then(
(success) => {
expect(success.length, "Expected schemas to be returned").to.greaterThan(0);
},
(fail) => {
expect.fail("failed on retrieving schemas");
}
);
});
2022-07-13 21:15:38 +02:00
it("validation", function () {
2021-10-04 12:08:55 +02:00
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
});
2022-06-13 23:36:37 +02:00
});
2021-08-18 20:15:02 +02:00
});