Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions test/specs/error-source/error-source.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("Report correct error source and path for", () => {
expect(err.errors).to.containSubset([
{
name: ResolverError.name,
source: path.abs("specs/error-source/broken-external.json"),
source: path.unixify(path.abs("specs/error-source/broken-external.json")),
path: ["components", "schemas", "testSchema", "properties", "test"],
message: message => typeof message === "string",
},
Expand All @@ -56,13 +56,13 @@ describe("Report correct error source and path for", () => {
expect(err.errors).to.containSubset([
{
name: MissingPointerError.name,
source: path.abs("specs/error-source/invalid-external.json"),
source: path.unixify(path.abs("specs/error-source/invalid-external.json")),
path: ["foo", "bar"],
message: message => typeof message === "string",
},
{
name: ResolverError.name,
source: path.abs("specs/error-source/broken-external.json"),
source: path.unixify(path.abs("specs/error-source/broken-external.json")),
path: ["components", "schemas", "testSchema", "properties", "test"],
message: message => typeof message === "string",
},
Expand All @@ -80,7 +80,7 @@ describe("Report correct error source and path for", () => {
expect(err.errors).to.containSubset([
{
name: InvalidPointerError.name,
source: path.abs("specs/error-source/invalid-pointer.json"),
source: path.unixify(path.abs("specs/error-source/invalid-pointer.json")),
path: ["foo", "baz"],
message: message => typeof message === "string",
},
Expand Down
2 changes: 1 addition & 1 deletion test/specs/invalid-pointers/invalid-pointers.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("Schema with invalid pointers", () => {
name: InvalidPointerError.name,
message: "Invalid $ref pointer \"f\". Pointers must begin with \"#/\"",
path: ["foo"],
source: path.abs("specs/invalid-pointers/invalid.json"),
source: path.unixify(path.abs("specs/invalid-pointers/invalid.json")),
}
]);
}
Expand Down
13 changes: 13 additions & 0 deletions test/utils/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ function filesystemPathHelpers () {
return file;
},

/**
* Returns the path with normalized, UNIX-like, slashes. Disk letter is lower-cased, if present.
*/
unixify (file) {
return file.replace(/\\/g, "/").replace(/^[A-Z](?=:\/)/, (letter) => letter.toLowerCase());
},

/**
* Returns the path of a file in the "test" directory as a URL.
* (e.g. "file://path/to/json-schema-ref-parser/test/files...")
Expand Down Expand Up @@ -111,6 +118,12 @@ function urlPathHelpers () {
return testsDir + encodePath(file);
},

/**
* Does nothing. Needed to comply with Filesystem path helpers.
*/
unixify (file) {
return file;
},
/**
* Returns the path of a file in the "test" directory as an absolute URL.
* (e.g. "http://localhost/test/files/...")
Expand Down