-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
40 lines (34 loc) · 1.42 KB
/
test.js
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
const assert = require("assert");
require("./index");
describe("Testing splitLines() prototype", function() {
it("should split lines without keeping line breaks", function() {
const text = "First line\nSecond line\r\nThird line\rFourth line";
const result = text.splitLines();
assert.deepStrictEqual(result, ["First line", "Second line", "Third line", "Fourth line"]);
});
it("should split lines and keep line breaks", function() {
const text = "First line\nSecond line\r\nThird line\rFourth line";
const result = text.splitLines(true);
assert.deepStrictEqual(result, ["First line\n", "Second line\r\n", "Third line\r", "Fourth line"]);
});
it("should handle empty string", function() {
const text = "";
const result = text.splitLines();
assert.deepStrictEqual(result, []);
});
it("should handle string without line breaks", function() {
const text = "String without line breaks";
const result = text.splitLines();
assert.deepStrictEqual(result, ["String without line breaks"]);
});
it("should handle string with only line breaks", function() {
const text = "\n\r\n\r";
const result = text.splitLines();
assert.deepStrictEqual(result, ["", "", ""]);
});
it("should handle string with only line breaks and keep them", function() {
const text = "\n\r\n\r";
const result = text.splitLines(true);
assert.deepStrictEqual(result, ["\n", "\r\n", "\r"]);
});
});