Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test harness upgrade #3510

Merged
merged 3 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/schema-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- uses: actions/checkout@v1 # checkout repo content
- uses: actions/setup-node@v4 # setup Node.js
with:
node-version: '14.x'
node-version: '20.x'
- name: Install dependencies
run: npm i
- name: Run tests
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"license": "Apache-2.0",
"scripts": {
"test": "npx mocha tests/**/test.js"
"test": "vitest --watch=false"
},
"readmeFilename": "README.md",
"files": [
Expand All @@ -27,10 +27,9 @@
"yargs": "^12.0.5"
},
"devDependencies": {
"@hyperjump/json-schema": "^0.17.0",
"chai": "^4.3.1",
"@hyperjump/json-schema": "^1.7.2",
"mdv": "^1.3.4",
"mocha": "^8.3.0",
"vitest": "^1.2.1",
"yaml": "^2.3.4"
},
"keywords": [
Expand Down
42 changes: 42 additions & 0 deletions tests/v3.1/schema.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { readdirSync, readFileSync } from "node:fs";
import YAML from "yaml";
import { validate, setMetaSchemaOutputFormat } from "@hyperjump/json-schema/openapi-3-1";
import { BASIC } from "@hyperjump/json-schema/experimental";
import { describe, test, expect } from "vitest";


const parseYamlFromFile = (filePath) => {
const schemaYaml = readFileSync(filePath, "utf8");
return YAML.parse(schemaYaml, { prettyErrors: true });
};

setMetaSchemaOutputFormat(BASIC);
// setShouldValidateSchema(false);

const validateOpenApi = await validate("./schemas/v3.1/schema.json");

describe("v3.1", () => {
describe("Pass", () => {
readdirSync(`./tests/v3.1/pass`, { withFileTypes: true })
.filter((entry) => entry.isFile() && /\.yaml$/.test(entry.name))
.forEach((entry) => {
test(entry.name, () => {
const instance = parseYamlFromFile(`./tests/v3.1/pass/${entry.name}`);
const output = validateOpenApi(instance, BASIC);
expect(output.valid).to.equal(true);
});
});
});

describe("Fail", () => {
readdirSync(`./tests/v3.1/fail`, { withFileTypes: true })
.filter((entry) => entry.isFile() && /\.yaml$/.test(entry.name))
.forEach((entry) => {
test(entry.name, () => {
const instance = parseYamlFromFile(`./tests/v3.1/fail/${entry.name}`);
const output = validateOpenApi(instance, BASIC);
expect(output.valid).to.equal(false);
});
});
});
});
48 changes: 0 additions & 48 deletions tests/v3.1/test.js

This file was deleted.

Loading