forked from javascript-tutorial/server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource.js
More file actions
executable file
·91 lines (69 loc) · 2.71 KB
/
Copy pathsource.js
File metadata and controls
executable file
·91 lines (69 loc) · 2.71 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
var extractHighlight = require('../../utils/source/extractHighlight');
var stripIndents = require('textUtil/stripIndents');
var fs = require('fs');
var path = require('path');
function readIn(name) {
return fs.readFileSync(path.join(__dirname, 'source/in', name), 'utf-8');
}
function readOut(name) {
return fs.readFileSync(path.join(__dirname, 'source/out', name), 'utf-8');
}
describe("source", function() {
describe("stripIndents", function() {
beforeEach(function() {
this.currentTest.in = readIn(this.currentTest.title);
this.currentTest.result = stripIndents(this.currentTest.in);
this.currentTest.out = readOut(this.currentTest.title);
});
it("indented.txt", function() {
this.test.result.should.be.eql(this.test.out);
});
});
describe("extractHighlight", function() {
beforeEach(function() {
this.currentTest.in = readIn(this.currentTest.title);
this.currentTest.result = extractHighlight(this.currentTest.in);
this.currentTest.out = readOut(this.currentTest.title);
});
it("block-whole.txt", function() {
this.test.result.inline.should.be.eql('');
this.test.result.block.should.be.eql('0-1');
this.test.result.text.should.be.eql(this.test.out);
});
it("block-one-line.txt", function() {
this.test.result.inline.should.be.eql('');
this.test.result.block.should.be.eql('0-0');
this.test.result.text.should.be.eql(this.test.out);
});
it("single-line.txt", function() {
this.test.result.inline.should.be.eql('');
this.test.result.block.should.be.eql('1-1');
this.test.result.text.should.be.eql(this.test.out);
});
it("blocks-two.txt", function() {
this.test.result.inline.should.be.eql('');
this.test.result.block.should.be.eql('1-2,4-4');
this.test.result.text.should.be.eql(this.test.out);
});
it("inline.txt", function() {
this.test.result.inline.should.be.eql('0:8-18');
this.test.result.block.should.be.eql('');
this.test.result.text.should.be.eql(this.test.out);
});
it("inline-multi.txt", function() {
this.test.result.inline.should.be.eql('0:8-18,1:8-9,1:18-19');
this.test.result.block.should.be.eql('');
this.test.result.text.should.be.eql(this.test.out);
});
it("mixed.txt", function() {
this.test.result.inline.should.be.eql('2:8-18,3:8-9');
this.test.result.block.should.be.eql('2-4');
this.test.result.text.should.be.eql(this.test.out);
});
it("big.txt", function() {
this.test.result.inline.should.be.eql('9:26-37,10:13-26');
this.test.result.block.should.be.eql('13-13,23-24');
this.test.result.text.should.be.eql(this.test.out);
});
});
});