-
-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathfile.spec.ts
More file actions
41 lines (36 loc) · 1.28 KB
/
file.spec.ts
File metadata and controls
41 lines (36 loc) · 1.28 KB
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
31
32
33
34
35
36
37
38
39
40
41
import * as util from "../util";
describe("JSON", () => {
test.each([0, "", [], [1, "2", []], { a: "b" }, { a: { b: "c" } }])("JSON (%p)", json => {
util.testModule(JSON.stringify(json)).setMainFileName("main.json").expectToEqual(json);
});
test("empty file throws runtime error", () => {
util.testModule("")
.setMainFileName("main.json")
.expectToEqual(new util.ExecutionError("Unexpected end of JSON input"));
});
test("JSON modules can be imported", () => {
util.testModule`
import * as jsonData from "./jsonModule.json";
export const result = jsonData;
`
.addExtraFile("jsonModule.json", '{ "jsonField1": "hello, this is JSON", "jsonField2": ["a", "b", "c"] }')
.expectToEqual({
result: {
jsonField1: "hello, this is JSON",
jsonField2: ["a", "b", "c"],
},
});
});
});
describe("shebang", () => {
test("LF", () => {
util.testModule`#!/usr/bin/env lua\n
const foo = true;
`.expectLuaToMatchSnapshot();
});
test("CRLF", () => {
util.testModule`#!/usr/bin/env lua\r\n
const foo = true;
`.expectLuaToMatchSnapshot();
});
});