mirror of
https://github.com/dhruvasagar/vim-table-mode.git
synced 2025-11-10 20:13:46 -05:00
Rewrite tests with vim-testify
This commit is contained in:
18
t/autoload/tablemode/table/add_border_test.vim
Normal file
18
t/autoload/tablemode/table/add_border_test.vim
Normal file
@@ -0,0 +1,18 @@
|
||||
source t/config/options.vim
|
||||
source t/utils.vim
|
||||
|
||||
let s:test_file = 't/fixtures/table/sample_for_header.txt'
|
||||
function! s:setup()
|
||||
call utils#TestSetup(s:test_file)
|
||||
endfunction
|
||||
call testify#setup(function('s:setup'))
|
||||
call testify#teardown(function('utils#TestTeardown'))
|
||||
|
||||
function! s:TestAddBorder()
|
||||
call testify#assert#assert(!tablemode#table#IsHeader(2))
|
||||
call tablemode#table#AddBorder(3)
|
||||
call testify#assert#assert(tablemode#table#IsHeader(2))
|
||||
call testify#assert#assert(tablemode#table#IsBorder(3))
|
||||
call utils#TestUndo(s:test_file)
|
||||
endfunction
|
||||
call testify#it('AddBorder should be able to add borders correctly', function('s:TestAddBorder'))
|
||||
37
t/autoload/tablemode/table/add_border_with_unicode_test.vim
Normal file
37
t/autoload/tablemode/table/add_border_with_unicode_test.vim
Normal file
@@ -0,0 +1,37 @@
|
||||
source t/config/options.vim
|
||||
source t/utils.vim
|
||||
|
||||
let s:test_file = 't/fixtures/table/sample_for_header_unicode.txt'
|
||||
function! s:setup()
|
||||
call utils#TestSetup(s:test_file)
|
||||
endfunction
|
||||
call testify#setup(function('s:setup'))
|
||||
call testify#teardown(function('utils#TestTeardown'))
|
||||
|
||||
function! s:TestAddBorder()
|
||||
call tablemode#table#AddBorder(2)
|
||||
call tablemode#table#AddBorder(4)
|
||||
call tablemode#table#AddBorder(6)
|
||||
call tablemode#table#AddBorder(8)
|
||||
call tablemode#table#AddBorder(10)
|
||||
|
||||
call testify#assert#assert(tablemode#table#IsHeader(3))
|
||||
|
||||
call testify#assert#assert(tablemode#table#IsBorder(2))
|
||||
call testify#assert#assert(tablemode#table#IsBorder(4))
|
||||
call testify#assert#assert(tablemode#table#IsBorder(6))
|
||||
call testify#assert#assert(tablemode#table#IsBorder(8))
|
||||
call testify#assert#assert(tablemode#table#IsBorder(10))
|
||||
|
||||
call testify#assert#equals(tablemode#utils#StrDisplayWidth(getline(2)), tablemode#utils#StrDisplayWidth(getline(3)))
|
||||
call testify#assert#equals(tablemode#utils#StrDisplayWidth(getline(3)), tablemode#utils#StrDisplayWidth(getline(4)))
|
||||
call testify#assert#equals(tablemode#utils#StrDisplayWidth(getline(4)), tablemode#utils#StrDisplayWidth(getline(5)))
|
||||
call testify#assert#equals(tablemode#utils#StrDisplayWidth(getline(5)), tablemode#utils#StrDisplayWidth(getline(6)))
|
||||
call testify#assert#equals(tablemode#utils#StrDisplayWidth(getline(6)), tablemode#utils#StrDisplayWidth(getline(7)))
|
||||
call testify#assert#equals(tablemode#utils#StrDisplayWidth(getline(7)), tablemode#utils#StrDisplayWidth(getline(8)))
|
||||
call testify#assert#equals(tablemode#utils#StrDisplayWidth(getline(8)), tablemode#utils#StrDisplayWidth(getline(9)))
|
||||
call testify#assert#equals(tablemode#utils#StrDisplayWidth(getline(9)), tablemode#utils#StrDisplayWidth(getline(10)))
|
||||
|
||||
call utils#TestUndo(s:test_file)
|
||||
endfunction
|
||||
call testify#it('AddBorder should be able to add borders correctly with unicode characters', function('s:TestAddBorder'))
|
||||
21
t/autoload/tablemode/table/is_border_test.vim
Normal file
21
t/autoload/tablemode/table/is_border_test.vim
Normal file
@@ -0,0 +1,21 @@
|
||||
source t/config/options.vim
|
||||
source t/utils.vim
|
||||
|
||||
let s:test_file = 't/fixtures/table/sample_with_header.txt'
|
||||
function! s:setup()
|
||||
call utils#TestSetup(s:test_file)
|
||||
endfunction
|
||||
call testify#setup(function('s:setup'))
|
||||
call testify#teardown(function('utils#TestTeardown'))
|
||||
|
||||
function! s:TestIsBorder()
|
||||
call testify#assert#assert(tablemode#table#IsBorder(2))
|
||||
call testify#assert#assert(tablemode#table#IsBorder(4))
|
||||
call testify#assert#assert(tablemode#table#IsBorder(7))
|
||||
|
||||
call testify#assert#assert(!tablemode#table#IsBorder(1))
|
||||
call testify#assert#assert(!tablemode#table#IsBorder(3))
|
||||
call testify#assert#assert(!tablemode#table#IsBorder(5))
|
||||
call testify#assert#assert(!tablemode#table#IsBorder(6))
|
||||
endfunction
|
||||
call testify#it('IsBorder should be correct', function('s:TestIsBorder'))
|
||||
21
t/autoload/tablemode/table/is_header_test.vim
Normal file
21
t/autoload/tablemode/table/is_header_test.vim
Normal file
@@ -0,0 +1,21 @@
|
||||
source t/config/options.vim
|
||||
source t/utils.vim
|
||||
|
||||
let s:test_file = 't/fixtures/table/sample_with_header.txt'
|
||||
function! s:setup()
|
||||
call utils#TestSetup(s:test_file)
|
||||
endfunction
|
||||
call testify#setup(function('s:setup'))
|
||||
call testify#teardown(function('utils#TestTeardown'))
|
||||
|
||||
function! s:TestIsHeader()
|
||||
call testify#assert#assert(tablemode#table#IsHeader(3))
|
||||
|
||||
call testify#assert#assert(!tablemode#table#IsHeader(1))
|
||||
call testify#assert#assert(!tablemode#table#IsHeader(2))
|
||||
call testify#assert#assert(!tablemode#table#IsHeader(4))
|
||||
call testify#assert#assert(!tablemode#table#IsHeader(5))
|
||||
call testify#assert#assert(!tablemode#table#IsHeader(6))
|
||||
call testify#assert#assert(!tablemode#table#IsHeader(7))
|
||||
endfunction
|
||||
call testify#it('IsHeader should be correct', function('s:TestIsHeader'))
|
||||
18
t/autoload/tablemode/table/is_row_test.vim
Normal file
18
t/autoload/tablemode/table/is_row_test.vim
Normal file
@@ -0,0 +1,18 @@
|
||||
source t/config/options.vim
|
||||
source t/utils.vim
|
||||
|
||||
let s:test_file = 't/fixtures/table/sample.txt'
|
||||
function! s:setup()
|
||||
call utils#TestSetup(s:test_file)
|
||||
endfunction
|
||||
call testify#setup(function('s:setup'))
|
||||
call testify#teardown(function('utils#TestTeardown'))
|
||||
|
||||
function! s:TestIsRow()
|
||||
call testify#assert#assert(tablemode#table#IsRow(3))
|
||||
call testify#assert#assert(tablemode#table#IsRow(4))
|
||||
|
||||
call testify#assert#assert(!tablemode#table#IsRow(1))
|
||||
call testify#assert#assert(!tablemode#table#IsRow(5))
|
||||
endfunction
|
||||
call testify#it('IsRow should be correct', function('s:TestIsRow'))
|
||||
25
t/autoload/tablemode/table/is_table_test.vim
Normal file
25
t/autoload/tablemode/table/is_table_test.vim
Normal file
@@ -0,0 +1,25 @@
|
||||
source t/config/options.vim
|
||||
source t/utils.vim
|
||||
|
||||
let s:test_file = 't/fixtures/table/sample_with_header.txt'
|
||||
function! s:setup()
|
||||
call utils#TestSetup(s:test_file)
|
||||
endfunction
|
||||
call testify#setup(function('s:setup'))
|
||||
call testify#teardown(function('utils#TestTeardown'))
|
||||
|
||||
function! s:TestIsTable()
|
||||
" when on row
|
||||
call testify#assert#assert(tablemode#table#IsTable(2))
|
||||
call testify#assert#assert(tablemode#table#IsTable(4))
|
||||
call testify#assert#assert(tablemode#table#IsTable(7))
|
||||
|
||||
" when on border
|
||||
call testify#assert#assert(tablemode#table#IsTable(3))
|
||||
call testify#assert#assert(tablemode#table#IsTable(5))
|
||||
call testify#assert#assert(tablemode#table#IsTable(6))
|
||||
|
||||
" when not in a table
|
||||
call testify#assert#assert(!tablemode#table#IsTable(1))
|
||||
endfunction
|
||||
call testify#it('IsTable should be correct', function('s:TestIsTable'))
|
||||
16
t/autoload/tablemode/table/realign_test.vim
Normal file
16
t/autoload/tablemode/table/realign_test.vim
Normal file
@@ -0,0 +1,16 @@
|
||||
source t/config/options.vim
|
||||
source t/utils.vim
|
||||
|
||||
let s:test_file = 't/fixtures/table/sample_realign_before.txt'
|
||||
function! s:setup()
|
||||
call utils#TestSetup(s:test_file)
|
||||
endfunction
|
||||
call testify#setup(function('s:setup'))
|
||||
call testify#teardown(function('utils#TestTeardown'))
|
||||
|
||||
function! s:TestRealign()
|
||||
call tablemode#table#Realign(2)
|
||||
call testify#assert#equals(getline(2, '$'), readfile('t/fixtures/table/sample_realign_after.txt'))
|
||||
call utils#TestUndo(s:test_file)
|
||||
endfunction
|
||||
call testify#it('Realign should align table properly', function('s:TestRealign'))
|
||||
@@ -0,0 +1,16 @@
|
||||
source t/config/options.vim
|
||||
source t/utils.vim
|
||||
|
||||
let s:test_file = 't/fixtures/table/sample_header_realign_before.txt'
|
||||
function! s:setup()
|
||||
call utils#TestSetup(s:test_file)
|
||||
endfunction
|
||||
call testify#setup(function('s:setup'))
|
||||
call testify#teardown(function('utils#TestTeardown'))
|
||||
|
||||
function! s:TestRealign()
|
||||
call tablemode#table#Realign(2)
|
||||
call testify#assert#equals(getline(2, '$'), readfile('t/fixtures/table/sample_header_realign_after.txt'))
|
||||
call utils#TestUndo(s:test_file)
|
||||
endfunction
|
||||
call testify#it('Realign should align table properly with header realignments', function('s:TestRealign'))
|
||||
@@ -0,0 +1,16 @@
|
||||
source t/config/options.vim
|
||||
source t/utils.vim
|
||||
|
||||
let s:test_file = 't/fixtures/table/sample_header_realign_unicode_before.txt'
|
||||
function! s:setup()
|
||||
call utils#TestSetup(s:test_file)
|
||||
endfunction
|
||||
call testify#setup(function('s:setup'))
|
||||
call testify#teardown(function('utils#TestTeardown'))
|
||||
|
||||
function! s:TestRealign()
|
||||
call tablemode#table#Realign(2)
|
||||
call testify#assert#equals(getline(2, '$'), readfile('t/fixtures/table/sample_header_realign_unicode_after.txt'))
|
||||
call utils#TestUndo(s:test_file)
|
||||
endfunction
|
||||
call testify#it('Realign should align table properly with header realignments and unicode characters', function('s:TestRealign'))
|
||||
16
t/autoload/tablemode/table/realign_with_unicode_test.vim
Normal file
16
t/autoload/tablemode/table/realign_with_unicode_test.vim
Normal file
@@ -0,0 +1,16 @@
|
||||
source t/config/options.vim
|
||||
source t/utils.vim
|
||||
|
||||
let s:test_file = 't/fixtures/table/sample_realign_unicode_before.txt'
|
||||
function! s:setup()
|
||||
call utils#TestSetup(s:test_file)
|
||||
endfunction
|
||||
call testify#setup(function('s:setup'))
|
||||
call testify#teardown(function('utils#TestTeardown'))
|
||||
|
||||
function! s:TestRealign()
|
||||
call tablemode#table#Realign(2)
|
||||
call testify#assert#equals(getline(2, '$'), readfile('t/fixtures/table/sample_realign_unicode_after.txt'))
|
||||
call utils#TestUndo(s:test_file)
|
||||
endfunction
|
||||
call testify#it('Realign should align table properly with unicode characters', function('s:TestRealign'))
|
||||
Reference in New Issue
Block a user