blob: 516467c2ba1fa95caf676c6d2409adfd3ade76a8 (
plain)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
" vim: fdm=indent
source t/config/options.vim
describe 'table'
describe 'IsRow'
before
new
normal! ggdG
read t/fixtures/table/sample.txt
end
it 'should be true when on a table row'
Expect tablemode#table#IsRow(2) to_be_true
Expect tablemode#table#IsRow(3) to_be_true
end
it 'should be false when not on a table row'
Expect tablemode#table#IsRow(1) to_be_false
Expect tablemode#table#IsRow(4) to_be_false
end
end
describe 'IsBorder'
before
new
normal! ggdG
read t/fixtures/table/sample_with_header.txt
end
it 'should be true on a table border'
Expect tablemode#table#IsBorder(1) to_be_true
Expect tablemode#table#IsBorder(3) to_be_true
Expect tablemode#table#IsBorder(6) to_be_true
end
it 'should be false when not on a table border'
Expect tablemode#table#IsBorder(2) to_be_false
Expect tablemode#table#IsBorder(4) to_be_false
Expect tablemode#table#IsBorder(5) to_be_false
end
end
describe 'IsTable'
before
new normal! ggdG
read t/fixtures/table/sample_with_header.txt
end
it 'should be true on a table row'
Expect tablemode#table#IsTable(2) to_be_true
Expect tablemode#table#IsTable(4) to_be_true
Expect tablemode#table#IsTable(5) to_be_true
end
it 'should be true when on a table border'
Expect tablemode#table#IsTable(1) to_be_true
Expect tablemode#table#IsTable(3) to_be_true
Expect tablemode#table#IsTable(6) to_be_true
end
it 'should not be true when not on a table'
Expect tablemode#table#IsTable(7) to_be_false
end
end
describe 'IsHeader'
before
new
normal! ggdG
read t/fixtures/table/sample_with_header.txt
end
it 'should be true on the table header'
Expect tablemode#table#IsHeader(2) to_be_true
end
it 'should be false anywhere else'
Expect tablemode#table#IsHeader(1) to_be_false
Expect tablemode#table#IsHeader(4) to_be_false
Expect tablemode#table#IsHeader(5) to_be_false
Expect tablemode#table#IsHeader(6) to_be_false
Expect tablemode#table#IsHeader(7) to_be_false
end
end
describe 'AddBorder'
before
new
normal! ggdG
read t/fixtures/table/sample_for_header.txt
end
it 'should add border to line'
call tablemode#table#AddBorder(2)
Expect tablemode#table#IsHeader(1) to_be_true
Expect tablemode#table#IsBorder(2) to_be_true
end
describe 'for unicode'
before
new
normal! ggdG
read t/fixtures/table/sample_for_header_unicode.txt
end
it 'should add border to line'
call tablemode#table#AddBorder(1)
call tablemode#table#AddBorder(3)
call tablemode#table#AddBorder(5)
call tablemode#table#AddBorder(7)
call tablemode#table#AddBorder(9)
Expect tablemode#table#IsBorder(1) to_be_true
Expect tablemode#utils#StrDisplayWidth(getline(1)) == tablemode#utils#StrDisplayWidth(getline(2))
Expect tablemode#table#IsBorder(3) to_be_true
Expect tablemode#utils#StrDisplayWidth(getline(3)) == tablemode#utils#StrDisplayWidth(getline(4))
Expect tablemode#table#IsBorder(5) to_be_true
Expect tablemode#utils#StrDisplayWidth(getline(5)) == tablemode#utils#StrDisplayWidth(getline(6))
Expect tablemode#table#IsBorder(7) to_be_true
Expect tablemode#utils#StrDisplayWidth(getline(7)) == tablemode#utils#StrDisplayWidth(getline(8))
Expect tablemode#table#IsBorder(9) to_be_true
Expect tablemode#utils#StrDisplayWidth(getline(9)) == tablemode#utils#StrDisplayWidth(getline(8))
end
end
end
describe 'Realign'
describe 'without header alignments'
describe 'for simple'
before
new
normal! ggdG
read t/fixtures/table/sample_realign_before.txt
end
it 'should be aligned properly'
call tablemode#table#Realign(1)
Expect getline(1,'$') == readfile('t/fixtures/table/sample_realign_after.txt')
end
end
describe 'for unicode'
before
new
normal! ggdG
read t/fixtures/table/sample_realign_unicode_before.txt
end
it 'should be aligned properly'
call tablemode#table#Realign(1)
Expect getline(1,'$') == readfile('t/fixtures/table/sample_realign_unicode_after.txt')
end
end
end
describe 'with header alignments'
describe 'for simple'
before
new
normal! ggdG
read t/fixtures/table/sample_header_realign_before.txt
end
it 'should be aligned properly'
call tablemode#table#Realign(1)
Expect getline(1,'$') == readfile('t/fixtures/table/sample_header_realign_after.txt')
end
end
describe 'for unicode'
before
new
normal! ggdG
read t/fixtures/table/sample_header_realign_unicode_before.txt
end
it 'should be aligned properly'
call tablemode#table#Realign(1)
Expect getline(1,'$') == readfile('t/fixtures/table/sample_header_realign_unicode_after.txt')
end
end
end
end
end
|