Skip to content

Commit c9c11b3

Browse files
committed
Update tests for browser
1 parent c482edd commit c9c11b3

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

test/specs/invalid/invalid.spec.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ describe("Invalid syntax", () => {
8282
expect(parser.errors).to.containSubset([
8383
{
8484
name: ResolverError.name,
85-
message: expectedValue => expectedValue.startsWith("Error opening file"),
85+
message: expectedValue => expectedValue.startsWith("Error opening file") || expectedValue.endsWith("HTTP ERROR 404"),
8686
path: [],
87-
source: expectedValue => expectedValue.endsWith("/test/this file does not exist"),
87+
source: expectedValue => expectedValue.endsWith("this file does not exist") || expectedValue.startsWith("http://localhost"),
8888
}
8989
]);
9090
});
@@ -198,13 +198,14 @@ describe("Invalid syntax", () => {
198198
it("should not throw an error for an invalid file path", async () => {
199199
const parser = new $RefParser();
200200
const result = await parser.dereference({ foo: { $ref: "this file does not exist" }}, { failFast: false });
201+
expect(result).to.deep.equal({ foo: null });
201202
expect(parser.errors.length).to.equal(1);
202203
expect(parser.errors).to.containSubset([
203204
{
204205
name: ResolverError.name,
205-
message: expectedValue => expectedValue.startsWith("Error opening file"),
206+
message: expectedValue => expectedValue.startsWith("Error opening file") || expectedValue.endsWith("HTTP ERROR 404"),
206207
path: ["foo"],
207-
source: expectedValue => expectedValue.endsWith("/test/"),
208+
source: expectedValue => expectedValue.endsWith("/test/") || expectedValue.startsWith("http://localhost"),
208209
}
209210
]);
210211
});
@@ -219,7 +220,7 @@ describe("Invalid syntax", () => {
219220
name: ParserError.name,
220221
message: "incomplete explicit mapping pair; a key node is missed",
221222
path: ["foo"],
222-
source: expectedValue => expectedValue.endsWith("/test/"),
223+
source: expectedValue => expectedValue.endsWith("/test/") || expectedValue.startsWith("http://localhost"),
223224
},
224225
]);
225226
});
@@ -234,7 +235,7 @@ describe("Invalid syntax", () => {
234235
name: ParserError.name,
235236
message: "unexpected end of the stream within a flow collection",
236237
path: ["foo"],
237-
source: expectedValue => expectedValue.endsWith("/test/"),
238+
source: expectedValue => expectedValue.endsWith("/test/") || expectedValue.startsWith("http://localhost"),
238239
}
239240
]);
240241
});
@@ -249,7 +250,7 @@ describe("Invalid syntax", () => {
249250
name: ParserError.name,
250251
message: "CloseBraceExpected",
251252
path: ["foo"],
252-
source: expectedValue => expectedValue.endsWith("/test/"),
253+
source: expectedValue => expectedValue.endsWith("/test/") || expectedValue.startsWith("http://localhost"),
253254
}
254255
]);
255256
});

test/specs/missing-pointers/missing-pointers.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe("Schema with missing pointers", () => {
2929
name: MissingPointerError.name,
3030
message: "Token \"baz\" does not exist.",
3131
path: ["foo"],
32-
source: expectedValue => expectedValue.endsWith("/test/"),
32+
source: expectedValue => expectedValue.endsWith("/test/") || expectedValue.startsWith("http://localhost"),
3333
}
3434
]);
3535
});

test/specs/parsers/parsers.spec.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
"use strict";
22

3-
const { expect } = require("chai");
3+
const chai = require("chai");
4+
const chaiSubset = require("chai-subset");
5+
chai.use(chaiSubset);
6+
const { expect } = chai;
47
const $RefParser = require("../../..");
58
const helper = require("../../utils/helper");
69
const path = require("../../utils/path");
@@ -221,7 +224,7 @@ describe("References to non-JSON files", () => {
221224
name: UnmatchedParserError.name,
222225
message: expectedValue => expectedValue.startsWith("Could not find parser for"),
223226
path: [],
224-
source: expectedValue => expectedValue.endsWith("specs/parsers/parsers.yaml"),
227+
source: expectedValue => expectedValue.endsWith("specs/parsers/parsers.yaml") || expectedValue.startsWith("http://localhost"),
225228
},
226229
]);
227230
});

0 commit comments

Comments
 (0)