Updated tests
This commit is contained in:
@@ -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());
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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 = <JsonSchema>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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user