Included Guilherme Victal works on overduedate
See https://github.com/freitass/todo.txt-vim/pull/45
This commit is contained in:
28
test/tc_date.todo.txt
Normal file
28
test/tc_date.todo.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
# lorem_ipsum
|
||||
example task
|
||||
# end_lorem_ipsum
|
||||
|
||||
# date_after_priority
|
||||
(A) Call Mom
|
||||
# end_date_after_priority
|
||||
|
||||
# date_after_priority_visual
|
||||
(A) Call Mom
|
||||
(B) Call Dad
|
||||
# end_date_after_priority_visual
|
||||
|
||||
# existing_date_no_priority
|
||||
2014-05-06 example task
|
||||
# end_existing_date_no_priority
|
||||
|
||||
# existing_date_after_priority
|
||||
(A) 2014-05-06 Call Mom
|
||||
# end_existing_date_after_priority
|
||||
|
||||
# existing_date_do_nothing
|
||||
2014-05-06 example task
|
||||
# end_existing_date_do_nothing
|
||||
|
||||
# non_existing_date_do_nothing
|
||||
new todo line
|
||||
# end_non_existing_date_do_nothing
|
||||
84
test/tc_date.vim
Normal file
84
test/tc_date.vim
Normal file
@@ -0,0 +1,84 @@
|
||||
let s:here = expand('<sfile>:p:h')
|
||||
let s:context = todo#txt#__context__()
|
||||
let s:context['data'] = s:here . '/tc_date.todo.txt'
|
||||
let s:tc = unittest#testcase#new('Date', s:context)
|
||||
|
||||
let s:TODAY = strftime("%Y-%m-%d")
|
||||
|
||||
function! s:tc.test_current_date()
|
||||
call self.assert_equal(s:TODAY, self.call('s:get_current_date', []))
|
||||
endfunction
|
||||
|
||||
let s:DATE_INSERTED = [
|
||||
\ s:TODAY . ' example task',
|
||||
\ ]
|
||||
|
||||
let s:DATE_INSERTED_AFTER_PRIORITY = [
|
||||
\ '(A) ' . s:TODAY . ' Call Mom',
|
||||
\ ]
|
||||
|
||||
let s:DATE_INSERTED_AFTER_PRIORITY_VISUAL = [
|
||||
\ '(A) ' . s:TODAY . ' Call Mom',
|
||||
\ '(B) ' . s:TODAY . ' Call Dad',
|
||||
\ ]
|
||||
|
||||
let s:DATE_INSERTED_DO_NOTHING = [
|
||||
\ '2014-05-06 example task',
|
||||
\ ]
|
||||
|
||||
let s:NON_EXISTING_DATE_INSERTED_DO_NOTHING = [
|
||||
\ s:TODAY . ' new todo line',
|
||||
\ ]
|
||||
|
||||
function! s:tc.test_insert_date_normal_mode()
|
||||
call self.data.goto('lorem_ipsum')
|
||||
call todo#txt#replace_date()
|
||||
call self.assert_equal(s:DATE_INSERTED, self.data.get('lorem_ipsum'))
|
||||
endfunction
|
||||
|
||||
function! s:tc.test_insert_date_insert_mode()
|
||||
call self.data.goto('lorem_ipsum')
|
||||
execute 'normal idate '
|
||||
call self.assert_equal(s:DATE_INSERTED, self.data.get('lorem_ipsum'))
|
||||
endfunction
|
||||
|
||||
function! s:tc.test_insert_date_visual_mode()
|
||||
call self.data.visual_execute('call todo#txt#replace_date()', 'lorem_ipsum')
|
||||
call self.assert_equal(s:DATE_INSERTED, self.data.get('lorem_ipsum'))
|
||||
endfunction
|
||||
|
||||
function! s:tc.test_insert_date_after_priority_normal_mode()
|
||||
call self.data.execute('call todo#txt#replace_date()', 'date_after_priority')
|
||||
call self.assert_equal(s:DATE_INSERTED_AFTER_PRIORITY, self.data.get('date_after_priority'))
|
||||
endfunction
|
||||
|
||||
function! s:tc.test_insert_date_after_priority_visual_mode()
|
||||
call self.data.visual_execute('call todo#txt#replace_date()', 'date_after_priority_visual')
|
||||
call self.assert_equal(s:DATE_INSERTED_AFTER_PRIORITY_VISUAL, self.data.get('date_after_priority_visual'))
|
||||
endfunction
|
||||
|
||||
function! s:tc.test_insert_with_existing_date()
|
||||
call self.data.execute('call todo#txt#replace_date()', 'existing_date_no_priority')
|
||||
call self.assert_equal(s:DATE_INSERTED, self.data.get('existing_date_no_priority'))
|
||||
endfunction
|
||||
|
||||
function! s:tc.test_insert_with_existing_date_and_priority()
|
||||
call self.data.execute('call todo#txt#replace_date()', 'existing_date_after_priority')
|
||||
call self.assert_equal(s:DATE_INSERTED_AFTER_PRIORITY, self.data.get('existing_date_after_priority'))
|
||||
endfunction
|
||||
|
||||
function! s:tc.test_insert_with_existing_date_and_priority()
|
||||
let g:todo_existing_date = 'n'
|
||||
call self.data.execute('call todo#txt#replace_date()', 'existing_date_do_nothing')
|
||||
call self.assert_equal(s:DATE_INSERTED_DO_NOTHING, self.data.get('existing_date_do_nothing'))
|
||||
unlet g:todo_existing_date
|
||||
endfunction
|
||||
|
||||
function! s:tc.test_insert_with_existing_date_and_priority()
|
||||
let g:todo_existing_date = 'n'
|
||||
call self.data.execute('call todo#txt#replace_date()', 'non_existing_date_do_nothing')
|
||||
call self.assert_equal(s:NON_EXISTING_DATE_INSERTED_DO_NOTHING, self.data.get('non_existing_date_do_nothing'))
|
||||
unlet g:todo_existing_date
|
||||
endfunction
|
||||
|
||||
unlet s:tc
|
||||
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
|
||||
2015-05-20 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:context = todo#txt#__context__()
|
||||
let s:context['data'] = s:here . '/tc_mark_as_done.todo.txt'
|
||||
let s:tc = unittest#testcase#new('Mark As Done', s:context)
|
||||
|
||||
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',
|
||||
\ '2015-05-20 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 . ' 2015-05-20 third task to be marked as done',
|
||||
\ ]
|
||||
|
||||
function! s:tc.test_mark_as_done()
|
||||
call self.data.goto('lorem_ipsum')
|
||||
call todo#txt#mark_as_done()
|
||||
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('call todo#txt#mark_as_done()', '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('call todo#txt#mark_as_done()', 'lorem_ipsum')
|
||||
call self.assert_equal(s:ALL_TASKS_DONE, self.data.get('lorem_ipsum'))
|
||||
endfunction
|
||||
|
||||
unlet s:tc
|
||||
7
test/tc_priority.todo.txt
Normal file
7
test/tc_priority.todo.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
# insert_priority
|
||||
example task
|
||||
# end_insert_priority
|
||||
|
||||
# replace_priority
|
||||
(A) example task
|
||||
# end_replace_priority
|
||||
28
test/tc_priority.vim
Normal file
28
test/tc_priority.vim
Normal file
@@ -0,0 +1,28 @@
|
||||
let s:here = expand('<sfile>:p:h')
|
||||
let s:context = todo#txt#__context__()
|
||||
let s:context['data'] = s:here . '/tc_priority.todo.txt'
|
||||
let s:tc = unittest#testcase#new('Priority', s:context)
|
||||
|
||||
let s:TODAY = strftime("%Y-%m-%d")
|
||||
|
||||
let s:PRIORITY_INSERTED = [
|
||||
\ '(A) example task',
|
||||
\ ]
|
||||
|
||||
let s:PRIORITY_REPLACED = [
|
||||
\ '(C) example task',
|
||||
\ ]
|
||||
|
||||
function! s:tc.test_insert_priority()
|
||||
call self.data.goto('insert_priority')
|
||||
call todo#txt#prioritize_add('A')
|
||||
call self.assert_equal(s:PRIORITY_INSERTED, self.data.get('insert_priority'))
|
||||
endfunction
|
||||
|
||||
function! s:tc.test_replace_priority()
|
||||
call self.data.goto('replace_priority')
|
||||
call todo#txt#prioritize_add('C')
|
||||
call self.assert_equal(s:PRIORITY_REPLACED, self.data.get('replace_priority'))
|
||||
endfunction
|
||||
|
||||
unlet s:tc
|
||||
5
test/tc_sort_context.todo.txt
Normal file
5
test/tc_sort_context.todo.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
# lorem_ipsum
|
||||
(B) Linear regression Rnet=Qh@Qle. @cons_emp_model
|
||||
(B) Review key questions. @benchmarking
|
||||
(A) simple model first @cons_emp_model
|
||||
# end_lorem_ipsum
|
||||
18
test/tc_sort_context.vim
Normal file
18
test/tc_sort_context.vim
Normal file
@@ -0,0 +1,18 @@
|
||||
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()
|
||||
call self.data.visual_execute('call todo#txt#sort_by_context()', 'lorem_ipsum')
|
||||
call self.assert_equal(s:SORTED_TASKS, self.data.get('lorem_ipsum'))
|
||||
endfunction
|
||||
|
||||
unlet s:tc
|
||||
12
test/tc_sort_date.todo.txt
Normal file
12
test/tc_sort_date.todo.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
# lorem_ipsum
|
||||
(B) 2013-03-15 2015-03-17
|
||||
(B) 2012-04-16 2015-04-16
|
||||
(A) 2013-03-16 2013-03-10
|
||||
# end_lorem_ipsum
|
||||
# task_with_no_date
|
||||
2013-03-15 task with date
|
||||
task with no date
|
||||
2013-03-15 task with date
|
||||
2013-03-15 task with date
|
||||
task with no date
|
||||
# end_task_with_no_date
|
||||
31
test/tc_sort_date.vim
Normal file
31
test/tc_sort_date.vim
Normal file
@@ -0,0 +1,31 @@
|
||||
let s:here = expand('<sfile>:p:h')
|
||||
let s:tc = unittest#testcase#new('Sort Date',
|
||||
\ { 'data': s:here . '/tc_sort_date.todo.txt' })
|
||||
|
||||
let s:LEADER = mapleader
|
||||
|
||||
let s:SORTED_TASKS = [
|
||||
\ '(B) 2012-04-16 2015-04-16',
|
||||
\ '(B) 2013-03-15 2015-03-17',
|
||||
\ '(A) 2013-03-16 2013-03-10',
|
||||
\ ]
|
||||
|
||||
let s:SORTED_TASKS_WITH_NO_DATE = [
|
||||
\ '2013-03-15 task with date',
|
||||
\ '2013-03-15 task with date',
|
||||
\ '2013-03-15 task with date',
|
||||
\ 'task with no date',
|
||||
\ 'task with no date',
|
||||
\ ]
|
||||
|
||||
function! s:tc.test_sort_by_date()
|
||||
call self.data.visual_execute('call todo#txt#sort_by_date()', 'lorem_ipsum')
|
||||
call self.assert_equal(s:SORTED_TASKS, self.data.get('lorem_ipsum'))
|
||||
endfunction
|
||||
|
||||
function! s:tc.test_sort_by_date_with_tasks_without_date()
|
||||
call self.data.visual_execute('call todo#txt#sort_by_date()', 'task_with_no_date')
|
||||
call self.assert_equal(s:SORTED_TASKS_WITH_NO_DATE, self.data.get('task_with_no_date'))
|
||||
endfunction
|
||||
|
||||
unlet s:tc
|
||||
5
test/tc_sort_project.todo.txt
Normal file
5
test/tc_sort_project.todo.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
# lorem_ipsum
|
||||
(B) Linear regression Rnet=Qh+Qle. +cons_emp_model
|
||||
(B) Review key questions. +benchmarking
|
||||
(A) simple model first +cons_emp_model
|
||||
# end_lorem_ipsum
|
||||
18
test/tc_sort_project.vim
Normal file
18
test/tc_sort_project.vim
Normal file
@@ -0,0 +1,18 @@
|
||||
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()
|
||||
call self.data.visual_execute('call todo#txt#sort_by_project()', '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