From 95ed508741af472ed02df51e234a112a02f2a2c9 Mon Sep 17 00:00:00 2001 From: Leandro Freitas Date: Sat, 11 Apr 2015 11:28:33 -0300 Subject: [PATCH] Added test cases for sorting and marking as done. --- ftplugin/todo.vim | 5 +++++ test/tc_mark_as_done.todo.txt | 5 +++++ test/tc_mark_as_done.vim | 36 +++++++++++++++++++++++++++++++++++ test/tc_sort_context.todo.txt | 3 +++ test/tc_sort_context.vim | 20 +++++++++++++++++++ test/tc_sort_project.todo.txt | 3 +++ test/tc_sort_project.vim | 20 +++++++++++++++++++ 7 files changed, 92 insertions(+) create mode 100644 test/tc_mark_as_done.todo.txt create mode 100644 test/tc_mark_as_done.vim create mode 100644 test/tc_sort_context.todo.txt create mode 100644 test/tc_sort_context.vim create mode 100644 test/tc_sort_project.todo.txt create mode 100644 test/tc_sort_project.vim diff --git a/ftplugin/todo.vim b/ftplugin/todo.vim index 915002c..24584a1 100644 --- a/ftplugin/todo.vim +++ b/ftplugin/todo.vim @@ -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 diff --git a/test/tc_mark_as_done.todo.txt b/test/tc_mark_as_done.todo.txt new file mode 100644 index 0000000..e706faf --- /dev/null +++ b/test/tc_mark_as_done.todo.txt @@ -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 diff --git a/test/tc_mark_as_done.vim b/test/tc_mark_as_done.vim new file mode 100644 index 0000000..f397df8 --- /dev/null +++ b/test/tc_mark_as_done.vim @@ -0,0 +1,36 @@ +let s:here = expand(':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 diff --git a/test/tc_sort_context.todo.txt b/test/tc_sort_context.todo.txt new file mode 100644 index 0000000..c74e59a --- /dev/null +++ b/test/tc_sort_context.todo.txt @@ -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 diff --git a/test/tc_sort_context.vim b/test/tc_sort_context.vim new file mode 100644 index 0000000..7a82c4e --- /dev/null +++ b/test/tc_sort_context.vim @@ -0,0 +1,20 @@ +let s:here = expand(':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 diff --git a/test/tc_sort_project.todo.txt b/test/tc_sort_project.todo.txt new file mode 100644 index 0000000..fbfc534 --- /dev/null +++ b/test/tc_sort_project.todo.txt @@ -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 diff --git a/test/tc_sort_project.vim b/test/tc_sort_project.vim new file mode 100644 index 0000000..ba71dd3 --- /dev/null +++ b/test/tc_sort_project.vim @@ -0,0 +1,20 @@ +let s:here = expand(':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