Added test cases for sorting and marking as done.
This commit is contained in:
@@ -9,6 +9,11 @@
|
|||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
|
" Export Context Dictionary for unit testing {{{1
|
||||||
|
function! todo#__context__()
|
||||||
|
return { 'sid': s:SID, 'scope': s: }
|
||||||
|
endfunction
|
||||||
|
|
||||||
" General options {{{1
|
" General options {{{1
|
||||||
" Some options lose their values when window changes. They will be set every
|
" Some options lose their values when window changes. They will be set every
|
||||||
" time this script is invocated, which is whenever a file of this type is
|
" time this script is invocated, which is whenever a file of this type is
|
||||||
|
|||||||
5
test/tc_mark_as_done.todo.txt
Normal file
5
test/tc_mark_as_done.todo.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# lorem_ipsum
|
||||||
|
first task to be marked as done
|
||||||
|
second task to be marked as done
|
||||||
|
third task to be marked as done
|
||||||
|
# end_lorem_ipsum
|
||||||
36
test/tc_mark_as_done.vim
Normal file
36
test/tc_mark_as_done.vim
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
let s:here = expand('<sfile>:p:h')
|
||||||
|
let s:tc = unittest#testcase#new('Mask As Done',
|
||||||
|
\ { 'data': s:here . '/tc_mark_as_done.todo.txt' })
|
||||||
|
|
||||||
|
let s:LEADER = mapleader
|
||||||
|
let s:TODAY = strftime("%Y-%m-%d")
|
||||||
|
|
||||||
|
let s:FIRST_TASK_DONE = [
|
||||||
|
\ 'x ' . s:TODAY . ' first task to be marked as done',
|
||||||
|
\ 'second task to be marked as done',
|
||||||
|
\ 'third task to be marked as done',
|
||||||
|
\ ]
|
||||||
|
|
||||||
|
let s:ALL_TASKS_DONE = [
|
||||||
|
\ 'x ' . s:TODAY . ' first task to be marked as done',
|
||||||
|
\ 'x ' . s:TODAY . ' second task to be marked as done',
|
||||||
|
\ 'x ' . s:TODAY . ' third task to be marked as done',
|
||||||
|
\ ]
|
||||||
|
|
||||||
|
function! s:tc.test_mark_as_done()
|
||||||
|
call self.data.goto('lorem_ipsum')
|
||||||
|
execute 'normal ' . s:LEADER . 'x'
|
||||||
|
call self.assert_equal(s:FIRST_TASK_DONE, self.data.get('lorem_ipsum'))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:tc.test_mark_range_as_done()
|
||||||
|
call self.data.execute('normal ' . s:LEADER . 'x', 'lorem_ipsum')
|
||||||
|
call self.assert_equal(s:ALL_TASKS_DONE, self.data.get('lorem_ipsum'))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:tc.test_mark_selection_as_done()
|
||||||
|
call self.data.visual_execute('normal ' . s:LEADER . 'x', 'lorem_ipsum')
|
||||||
|
call self.assert_equal(s:ALL_TASKS_DONE, self.data.get('lorem_ipsum'))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
unlet s:tc
|
||||||
3
test/tc_sort_context.todo.txt
Normal file
3
test/tc_sort_context.todo.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
(B) Linear regression Rnet=Qh@Qle. @cons_emp_model
|
||||||
|
(B) Review key questions. @benchmarking
|
||||||
|
(A) simple model first @cons_emp_model
|
||||||
20
test/tc_sort_context.vim
Normal file
20
test/tc_sort_context.vim
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
let s:here = expand('<sfile>:p:h')
|
||||||
|
let s:tc = unittest#testcase#new('Sort Context',
|
||||||
|
\ { 'data': s:here . '/tc_sort_context.todo.txt' })
|
||||||
|
|
||||||
|
let s:LEADER = mapleader
|
||||||
|
|
||||||
|
let s:SORTED_TASKS = [
|
||||||
|
\ '(B) Review key questions. @benchmarking',
|
||||||
|
\ '(B) Linear regression Rnet=Qh@Qle. @cons_emp_model',
|
||||||
|
\ '(A) simple model first @cons_emp_model',
|
||||||
|
\ ]
|
||||||
|
|
||||||
|
function! s:tc.test_sort_by_context()
|
||||||
|
execute 'normal ' . s:LEADER . 's@'
|
||||||
|
execute 'normal ggO# lorem_ipsum'
|
||||||
|
execute 'normal Go# end_lorem_ipsum'
|
||||||
|
call self.assert_equal(s:SORTED_TASKS, self.data.get('lorem_ipsum'))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
unlet s:tc
|
||||||
3
test/tc_sort_project.todo.txt
Normal file
3
test/tc_sort_project.todo.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
(B) Linear regression Rnet=Qh+Qle. +cons_emp_model
|
||||||
|
(B) Review key questions. +benchmarking
|
||||||
|
(A) simple model first +cons_emp_model
|
||||||
20
test/tc_sort_project.vim
Normal file
20
test/tc_sort_project.vim
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
let s:here = expand('<sfile>:p:h')
|
||||||
|
let s:tc = unittest#testcase#new('Sort Project',
|
||||||
|
\ { 'data': s:here . '/tc_sort_project.todo.txt' })
|
||||||
|
|
||||||
|
let s:LEADER = mapleader
|
||||||
|
|
||||||
|
let s:SORTED_TASKS = [
|
||||||
|
\ '(B) Review key questions. +benchmarking',
|
||||||
|
\ '(B) Linear regression Rnet=Qh+Qle. +cons_emp_model',
|
||||||
|
\ '(A) simple model first +cons_emp_model',
|
||||||
|
\ ]
|
||||||
|
|
||||||
|
function! s:tc.test_sort_by_project()
|
||||||
|
execute 'normal ' . s:LEADER . 's+'
|
||||||
|
execute 'normal ggO# lorem_ipsum'
|
||||||
|
execute 'normal Go# end_lorem_ipsum'
|
||||||
|
call self.assert_equal(s:SORTED_TASKS, self.data.get('lorem_ipsum'))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
unlet s:tc
|
||||||
Reference in New Issue
Block a user