mirror of
https://github.com/dhruvasagar/vim-table-mode.git
synced 2025-11-08 11:03:47 -05:00
Added more tests for Realigning unicode content
This commit is contained in:
9
t/fixtures/table/sample_for_header_unicode.txt
Normal file
9
t/fixtures/table/sample_for_header_unicode.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
| abc | 测试长度 | 长测试 |
|
||||||
|
|
||||||
|
| 长 | 测试测试测试测试 | 测试测试 |
|
||||||
|
|
||||||
|
| 测试测试 | 测试 | 测试测测试 |
|
||||||
|
|
||||||
|
| 测试测试测试 | 测试测试 | 测试 |
|
||||||
|
|
||||||
8
t/fixtures/table/sample_header_realign_unicode_after.txt
Normal file
8
t/fixtures/table/sample_header_realign_unicode_after.txt
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
|--------------+------------------+------------|
|
||||||
|
| 测试测试 | 测试长度 | 长测试 |
|
||||||
|
|--------------+------------------+-----------:|
|
||||||
|
| abc | 测试长度 | 长测试 |
|
||||||
|
| 长 | 测试测试测试测试 | 测试测试 |
|
||||||
|
| 测试测试 | 测试 | 测试测测试 |
|
||||||
|
| 测试测试测试 | 测试测试 | 测试 |
|
||||||
|
|--------------+------------------+------------|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
|--------+--------+------|
|
||||||
|
|测试测试|测试长度|长测试|
|
||||||
|
|--------+--------+-----:|
|
||||||
|
|abc|测试长度|长测试|
|
||||||
|
|长|测试测试测试测试|测试测试|
|
||||||
|
|测试测试|测试|测试测测试|
|
||||||
|
|测试测试测试|测试测试|测试|
|
||||||
|
|------------+--------+----|
|
||||||
4
t/fixtures/table/sample_realign_unicode_after.txt
Normal file
4
t/fixtures/table/sample_realign_unicode_after.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
| abc | 测试长度 | 长测试 |
|
||||||
|
| 长 | 测试测试测试测试 | 测试测试 |
|
||||||
|
| 测试测试 | 测试 | 测试测测试 |
|
||||||
|
| 测试测试测试 | 测试测试 | 测试 |
|
||||||
4
t/fixtures/table/sample_realign_unicode_before.txt
Normal file
4
t/fixtures/table/sample_realign_unicode_before.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
|abc|测试长度|长测试|
|
||||||
|
|长|测试测试测试测试|测试测试|
|
||||||
|
|测试测试|测试|测试测测试|
|
||||||
|
|测试测试测试|测试测试|测试|
|
||||||
52
t/table.vim
52
t/table.vim
@@ -70,6 +70,32 @@ describe 'table'
|
|||||||
Expect tablemode#table#IsHeader(1) to_be_true
|
Expect tablemode#table#IsHeader(1) to_be_true
|
||||||
Expect tablemode#table#IsBorder(2) to_be_true
|
Expect tablemode#table#IsBorder(2) to_be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'for unicode'
|
||||||
|
before
|
||||||
|
new
|
||||||
|
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
|
end
|
||||||
|
|
||||||
describe 'Realign'
|
describe 'Realign'
|
||||||
@@ -83,6 +109,19 @@ describe 'table'
|
|||||||
call tablemode#table#Realign(1)
|
call tablemode#table#Realign(1)
|
||||||
Expect getline(1,'$') == readfile('t/fixtures/table/sample_realign_after.txt')
|
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
|
end
|
||||||
|
|
||||||
describe 'with header alignments'
|
describe 'with header alignments'
|
||||||
@@ -95,6 +134,19 @@ describe 'table'
|
|||||||
call tablemode#table#Realign(1)
|
call tablemode#table#Realign(1)
|
||||||
Expect getline(1,'$') == readfile('t/fixtures/table/sample_header_realign_after.txt')
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user