From ced5441358e19a7a123a0d4e389e521b665a55f7 Mon Sep 17 00:00:00 2001 From: DaanV2 Date: Wed, 13 Jul 2022 21:15:38 +0200 Subject: [PATCH] Updated tests --- test/src/Utillity.test.ts | 8 ++++---- test/src/Validator.test.ts | 16 +++++++++------- test/src/files/correct.test.ts | 8 ++++---- test/src/files/incorrect.test.ts | 8 ++++---- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/test/src/Utillity.test.ts b/test/src/Utillity.test.ts index b972a3a4..b10d1584 100644 --- a/test/src/Utillity.test.ts +++ b/test/src/Utillity.test.ts @@ -2,8 +2,8 @@ import { expect } from "chai"; import { DummyFiles } from "../../src/main"; import { Files } from "./Utillity"; -describe("Files", () => { - it("Root", () => { +describe("Files", function () { + it("Root", function () { const temp = Files.RootFolder(); expect(temp.endsWith("lib"), "ended with lib").to.be.false; @@ -11,13 +11,13 @@ describe("Files", () => { expect(temp.endsWith("lib/test"), "ended with lib/test").to.be.false; }); - it("Test", () => { + it("Test", function () { const temp = Files.TestFolder(); expect(temp.endsWith("lib"), "ended with lib").to.be.false; }); - it("Random", () => { + it("Random", function () { expect(Files.TestFolder()).to.equal(DummyFiles.TestFolder()); }); }); diff --git a/test/src/Validator.test.ts b/test/src/Validator.test.ts index bb18653a..7531631b 100644 --- a/test/src/Validator.test.ts +++ b/test/src/Validator.test.ts @@ -4,7 +4,7 @@ import * as fs from "fs"; import * as JSONC from "comment-json"; import { expect } from "chai"; -describe.only("Validate", () => { +describe.only("Validate", function () { const folder = path.join(Files.TestFolder(), "..", "source"); console.log(folder); const files = Files.GetFiles(folder); @@ -12,24 +12,24 @@ describe.only("Validate", () => { files.forEach((filepath) => { const filename = filepath.slice(folder.length); - describe(filename, () => { + describe(filename, function () { let object: JsonSchema | undefined = undefined; let data: string; - it("Can read file", () => { + it("Can read file", function () { data = fs.readFileSync(filepath, "utf8"); }); - it("Can parse to json", () => { + it("Can parse to json", function () { object = JSONC.parse(data); }); - it("Not Undefined or null", () => { + it("Not Undefined or null", function () { expect(object).to.not.be.undefined; expect(object).to.not.be.null; }); - it("Checking refs", () => { + describe("Checking refs", function () { if (!object) { expect.fail(); return; @@ -53,7 +53,9 @@ function explore_refs(data: JsonSchema, folder: string): void { if (!ref.startsWith("#")) { const filepath = path.isAbsolute(ref) ? ref : path.join(folder, ref); - expect(fs.existsSync(filepath), `ref ${ref} exists`).to.be.true; + it(`expecting ${ref} to exist from ${folder}`, function () { + expect(fs.existsSync(filepath), `ref ${ref} exists`).to.be.true; + }); } } diff --git a/test/src/files/correct.test.ts b/test/src/files/correct.test.ts index 4e23ae10..d3dd7826 100644 --- a/test/src/files/correct.test.ts +++ b/test/src/files/correct.test.ts @@ -2,7 +2,7 @@ import { expect } from "chai"; import { Schema } from "../SchemaTester"; import { Files } from "../Utillity"; -describe("test correct files", () => { +describe("test correct files", function () { const folder = Files.CorrectFilesFolder().replace(/\\/gi, "/"); const files = Files.GetFiles(folder); const validator = Schema.GetValidator(); @@ -14,11 +14,11 @@ describe("test correct files", () => { .forEach((file) => { const testfolder = file.replace(folder + "/", ""); - describe(testfolder, () => { + describe(testfolder, function () { const result = validator.ValidateFile(file); const schemas = validator.ls.getMatchingSchemas(result.doc, result.jdoc); - it("validation", () => { + it("validation", function () { result.promise.then( (succes) => { expect(succes.length, "Expected no errors got: " + succes.length).to.equal(0); @@ -32,7 +32,7 @@ describe("test correct files", () => { return result.promise; }); - it("schemas", () => { + it("schemas", function () { return schemas.then( (success) => { expect(success.length, "Expected schemas to be returned").to.greaterThan(0); diff --git a/test/src/files/incorrect.test.ts b/test/src/files/incorrect.test.ts index 90b90ea4..a74df48d 100644 --- a/test/src/files/incorrect.test.ts +++ b/test/src/files/incorrect.test.ts @@ -2,7 +2,7 @@ import { expect } from "chai"; import { Schema } from "../SchemaTester"; import { Files } from "../Utillity"; -describe("test incorrect files", () => { +describe("test incorrect files", function () { const folder = Files.InCorrectFilesFolder().replace(/\\/gi, "/"); const files = Files.GetFiles(folder); const validator = Schema.GetValidator(); @@ -14,11 +14,11 @@ describe("test incorrect files", () => { .forEach((file) => { const testfolder = file.replace(folder + "/", ""); - describe(testfolder, () => { + describe(testfolder, function () { const result = validator.ValidateFile(file); const schemas = validator.ls.getMatchingSchemas(result.doc, result.jdoc); - it("schemas", () => { + it("schemas", function () { return schemas.then( (success) => { expect(success.length, "Expected schemas to be returned").to.greaterThan(0); @@ -29,7 +29,7 @@ describe("test incorrect files", () => { ); }); - it("validation", () => { + it("validation", function () { result.promise.then( (succes) => { expect(succes.length, "Expected errors! but had none").to.greaterThan(0);