-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.tst.ts
More file actions
72 lines (62 loc) · 1.79 KB
/
Copy pathindex.tst.ts
File metadata and controls
72 lines (62 loc) · 1.79 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/// <reference lib="dom" />
/// <reference types="node" />
import type { JsonError } from "@datastream/json";
import {
jsonFormatStream,
jsonParseStream,
ndjsonFormatStream,
ndjsonParseStream,
} from "@datastream/json";
import { describe, expect, test } from "tstyche";
describe("JsonError", () => {
test("has required fields", () => {
expect<JsonError>().type.toBeAssignableTo<{
id: string;
message: string;
idx: number[];
}>();
});
});
describe("ndjsonParseStream", () => {
test("returns stream with result", () => {
const stream = ndjsonParseStream();
expect(stream.result).type.not.toBeAssignableTo<never>();
});
test("accepts maxBufferSize", () => {
expect(
ndjsonParseStream({ maxBufferSize: 1024 }),
).type.not.toBeAssignableTo<never>();
});
test("accepts resultKey", () => {
expect(
ndjsonParseStream({ resultKey: "myErrors" }),
).type.not.toBeAssignableTo<never>();
});
});
describe("ndjsonFormatStream", () => {
test("accepts no options", () => {
expect(ndjsonFormatStream()).type.not.toBeAssignableTo<never>();
});
test("accepts space option", () => {
expect(ndjsonFormatStream({ space: 2 })).type.not.toBeAssignableTo<never>();
});
});
describe("jsonParseStream", () => {
test("returns stream with result", () => {
const stream = jsonParseStream();
expect(stream.result).type.not.toBeAssignableTo<never>();
});
test("accepts maxBufferSize and maxValueSize", () => {
expect(
jsonParseStream({ maxBufferSize: 1024, maxValueSize: 512 }),
).type.not.toBeAssignableTo<never>();
});
});
describe("jsonFormatStream", () => {
test("accepts no options", () => {
expect(jsonFormatStream()).type.not.toBeAssignableTo<never>();
});
test("accepts space option", () => {
expect(jsonFormatStream({ space: 2 })).type.not.toBeAssignableTo<never>();
});
});