forked from TypeScriptToLua/TypeScriptToLua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson.spec.ts
More file actions
23 lines (20 loc) · 704 Bytes
/
json.spec.ts
File metadata and controls
23 lines (20 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import * as TSTLErrors from "../../src/TSTLErrors";
import * as util from "../util";
import * as ts from "typescript";
const jsonOptions = {
resolveJsonModule: true,
noHeader: true,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
};
test.each([0, "", [], [1, "2", []], { a: "b" }, { a: { b: "c" } }])("JSON (%p)", json => {
util.testModule(JSON.stringify(json))
.setOptions(jsonOptions)
.setMainFileName("main.json")
.expectToEqual(json);
});
test("Empty JSON", () => {
util.testModule("")
.setOptions(jsonOptions)
.setMainFileName("main.json")
.expectToHaveDiagnosticOfError(TSTLErrors.InvalidJsonFileContent(util.nodeStub));
});