Skip to content

Commit e121717

Browse files
Basic tests setup for ISSUE-200.
1 parent baa7853 commit e121717

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed

test/specs/extended-ref/base.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": "object",
3+
"properties": {
4+
"some_value": { "$ref": "defs1.json#/definitions/astring" }
5+
}
6+
}

test/specs/extended-ref/defs1.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"definitions": {
3+
"astring": {
4+
"description": "astring",
5+
"$ref": "defs2.json#/definitions/bstring"
6+
}
7+
}
8+
}

test/specs/extended-ref/defs2.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"definitions": {
3+
"bstring": {
4+
"oneOf": [
5+
{
6+
"$ref": "#/definitions/cstring"
7+
},
8+
{
9+
"$ref": "#/definitions/dstring"
10+
}
11+
]
12+
},
13+
"cstring": {
14+
"type": "string"
15+
},
16+
"dstring": {
17+
"type": "number"
18+
}
19+
}
20+
}
21+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"use strict";
2+
3+
const $RefParser = require("../../..");
4+
const helper = require("../../utils/helper");
5+
const path = require("../../utils/path");
6+
const { expect } = require("chai");
7+
// const parsedSchema = require("./parsed");
8+
// const dereferencedSchema = require("./dereferenced");
9+
10+
describe("File names with special characters", () => {
11+
it("should parse successfully", async () => {
12+
let parser = new $RefParser();
13+
const schema = await parser.dereference(path.rel("specs/extended-ref/base.json"));
14+
expect(schema).to.equal(parser.schema);
15+
// expect(schema).to.deep.equal(parsedSchema.schema);
16+
// expect(parser.$refs.paths()).to.deep.equal([path.abs("specs/__({[ % & $ # @ ` ~ ,)}]__/__({[ % & $ # @ ` ~ ,)}]__.yaml")]);
17+
});
18+
19+
// it("should resolve successfully", helper.testResolve(
20+
// path.rel("specs/__({[ % & $ # @ ` ~ ,)}]__/__({[ % & $ # @ ` ~ ,)}]__.yaml"),
21+
// path.abs("specs/__({[ % & $ # @ ` ~ ,)}]__/__({[ % & $ # @ ` ~ ,)}]__.yaml"), parsedSchema.schema,
22+
// path.abs("specs/__({[ % & $ # @ ` ~ ,)}]__/__({[ % & $ # @ ` ~ ,)}]__/__({[ % & $ # @ ` ~ ,)}]__.json"), parsedSchema.file
23+
// ));
24+
25+
// it("should dereference successfully", async () => {
26+
// let parser = new $RefParser();
27+
// const schema = await parser.dereference(path.rel("specs/__({[ % & $ # @ ` ~ ,)}]__/__({[ % & $ # @ ` ~ ,)}]__.yaml"));
28+
// expect(schema).to.equal(parser.schema);
29+
// expect(schema).to.deep.equal(dereferencedSchema);
30+
// // The "circular" flag should NOT be set
31+
// expect(parser.$refs.circular).to.equal(false);
32+
// });
33+
34+
// it("should bundle successfully", async () => {
35+
// let parser = new $RefParser();
36+
// const schema = await parser.bundle(path.rel("specs/__({[ % & $ # @ ` ~ ,)}]__/__({[ % & $ # @ ` ~ ,)}]__.yaml"));
37+
// expect(schema).to.equal(parser.schema);
38+
// expect(schema).to.deep.equal(dereferencedSchema);
39+
// });
40+
});

0 commit comments

Comments
 (0)