-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathloadCJSON.spec.ts
More file actions
30 lines (26 loc) · 966 Bytes
/
loadCJSON.spec.ts
File metadata and controls
30 lines (26 loc) · 966 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { expect } from "chai";
import * as path from "path";
import { loadCJSON } from "./loadCJSON";
import { FirebaseError } from "./error";
describe("loadCJSON", () => {
const fixturesDir = path.join(__dirname, "test", "fixtures", "loadCJSON");
it("should return parsed JSON on success", () => {
const filePath = path.join(fixturesDir, "valid.cjson");
const result = loadCJSON(filePath);
expect(result).to.deep.equal({ key: "value" });
});
it("should throw FirebaseError on ENOENT", () => {
const filePath = path.join(fixturesDir, "nonexistent.cjson");
expect(() => loadCJSON(filePath)).to.throw(
FirebaseError,
"File " + filePath + " does not exist",
);
});
it("should throw FirebaseError on parse error", () => {
const filePath = path.join(fixturesDir, "invalid.cjson");
expect(() => loadCJSON(filePath)).to.throw(
FirebaseError,
new RegExp(`Parse Error in ${filePath}`),
);
});
});