Added test cases for sorting and marking as done.

This commit is contained in:
Leandro Freitas
2015-04-11 11:28:33 -03:00
parent 05b5be07d2
commit 95ed508741
7 changed files with 92 additions and 0 deletions

View File

@@ -9,6 +9,11 @@
let s:save_cpo = &cpo
set cpo&vim
" Export Context Dictionary for unit testing {{{1
function! todo#__context__()
return { 'sid': s:SID, 'scope': s: }
endfunction
" General options {{{1
" 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

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

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

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