Rewrite tests with vim-testify

This commit is contained in:
Dhruva Sagar
2023-03-01 07:22:48 +05:30
parent 9555a3e6e5
commit 7ec0b83dbd
37 changed files with 1241 additions and 862 deletions

View 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'))

View 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'))

View 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'))

View 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'))

View 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'))

View 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'))

View 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'))

View File

@@ -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'))

View File

@@ -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'))

View 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'))