This commit is contained in:
Leandro Freitas
2015-05-05 09:37:02 -03:00
parent 51c821b5da
commit 40faa56012
3 changed files with 31 additions and 5 deletions

View File

@@ -26,7 +26,7 @@ function! s:get_current_date()
endfunction
function! todo#txt#prepend_date()
execute 'normal! 0"='.string(s:get_current_date().' ').'
execute 's/^\(([a-zA-Z]) \)\?/\1' . s:get_current_date() . ' /'
endfunction
function! todo#txt#mark_as_done()

View File

@@ -1,3 +1,12 @@
# 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

View File

@@ -13,8 +13,13 @@ let s:DATE_INSERTED = [
\ s:TODAY . ' example task',
\ ]
let s:DATE_INSERTED_VISUAL = [
\ 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',
\ ]
function! s:tc.test_insert_date_normal_mode()
@@ -26,12 +31,24 @@ 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_VISUAL, self.data.get('lorem_ipsum'))
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#prepend_date()', 'lorem_ipsum')
call self.assert_equal(s:DATE_INSERTED_VISUAL, self.data.get('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.goto('date_after_priority')
call self.data.execute('call todo#txt#prepend_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.goto('date_after_priority_visual')
call self.data.visual_execute('call todo#txt#prepend_date()', 'date_after_priority_visual')
call self.assert_equal(s:DATE_INSERTED_AFTER_PRIORITY_VISUAL, self.data.get('date_after_priority_visual'))
endfunction
unlet s:tc