-
Notifications
You must be signed in to change notification settings - Fork 696
Expand file tree
/
Copy pathconvenient_line.js
More file actions
69 lines (57 loc) · 1.84 KB
/
convenient_line.js
File metadata and controls
69 lines (57 loc) · 1.84 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
var assert = require("assert");
var repoSetup = require("../utils/repository_setup");
var promisify = require("promisify-node");
var fse = promisify(require("fs-extra"));
var path = require("path");
var local = path.join.bind(path, __dirname);
describe("ConvenientLine", function() {
var repoPath = local("../repos/convenientLineTest");
var unicodeLine = "Ťḥ𝖎ṧ ℓỈ𝓃ệ çǒ𝚗ẗảḭṋṦ Û𝐧ǐ𝗰ṓḍ𝔢\n";
var asciiLine = "but this line doesn't\n";
beforeEach(function() {
var test = this;
return repoSetup.createRepository(repoPath)
.then(function(repo) {
return repoSetup.commitFileToRepo(
repo,
"fileWithUnicodeChars",
unicodeLine + asciiLine
);
})
.then(function(commit) {
return commit.getDiff();
})
.then(function(diff) {
return diff[0].patches();
})
.then(function(patches) {
return patches[0].hunks();
})
.then(function(hunks) {
return hunks[0].lines();
})
.then(function(lines) {
test.unicodeLine = lines[0];
test.asciiLine = lines[1];
});
});
after(function() {
return fse.remove(repoPath);
});
it("can parse the byte length of a unicode string", function() {
var line = this.unicodeLine;
assert.equal(line.contentLen(), Buffer.byteLength(unicodeLine, "utf8"));
});
it("can get a line that contains unicode", function() {
var line = this.unicodeLine;
assert.equal(line.content(), unicodeLine);
});
it("can parse the byte length of a ascii string", function() {
var line = this.asciiLine;
assert.equal(line.contentLen(), Buffer.byteLength(asciiLine, "utf8"));
});
it("can get a line that contains ascii", function() {
var line = this.asciiLine;
assert.equal(line.content(), asciiLine);
});
});