-
Notifications
You must be signed in to change notification settings - Fork 0
/
lines.spec.ts
44 lines (39 loc) · 1.27 KB
/
lines.spec.ts
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
import { sf } from "./index";
import { lines } from "./lines";
it("split string stream into lines stream", async () => {
expect(
await sf("a,b,c\n1,2,3\n\nd,s,f".split(""))
.through(lines({ EOL: "NONE" }))
.toArray(),
).toEqual(["a,b,c", "1,2,3", "", "d,s,f"]);
expect(
await sf("a,b,c\n1,2,3\n\nd,s,f")
.through(lines({ EOL: "NONE" }))
.toArray(),
).toEqual(["a,b,c", "1,2,3", "", "d,s,f"]);
expect(
await sf(["a,b,c\n1,", "2,3\n\nd,s,f"]).lines({ EOL: "NONE" }).toArray(),
).toEqual(["a,b,c", "1,2,3", "", "d,s,f"]);
});
it("Change EOL", async () => {
expect(
await sf("a,b,c\n1,2,3\n\nd,s,f".split(""))
.through(lines({ EOL: "LF" }))
.toArray(),
).toEqual(["a,b,c\n", "1,2,3\n", "\n", "d,s,f\n"]);
expect(
await sf("a,b,c\n1,2,3\n\nd,s,f".split(""))
.through(lines({ EOL: "CRLF" }))
.toArray(),
).toEqual(["a,b,c\r\n", "1,2,3\r\n", "\r\n", "d,s,f\r\n"]);
expect(
await sf("a,b,c\n1,2,3\n\r\nd,s,f".split(""))
.through(lines({ EOL: "KEEP" }))
.toArray(),
).toEqual(["a,b,c\n", "1,2,3\n", "\r\n", "d,s,f"]);
expect(
await sf("a,b,c\n1,2,3\n\r\nd,s,f\n".split(""))
.through(lines({ EOL: "KEEP" }))
.toArray(),
).toEqual(["a,b,c\n", "1,2,3\n", "\r\n", "d,s,f\n"]);
});