@@ -442,23 +442,61 @@ describe('Mappings', function()
442442 ' ' ,
443443 ' * TODO Test orgmode' ,
444444 ' - Regular item' ,
445- ' - Second recular item' ,
445+ ' - Second regular item' ,
446446 ' - Nested item' ,
447+ ' - [x] Checkbox item' ,
448+ ' - [x] Second checkbox item' ,
449+ ' - [x] Nested checkbox item' ,
447450 })
448451
449452 assert .are .same ({
450453 ' - Regular item' ,
451- ' - Second recular item' ,
454+ ' - Second regular item' ,
452455 ' - Nested item' ,
453- }, vim .api .nvim_buf_get_lines (0 , 3 , 6 , false ))
456+ ' - [x] Checkbox item' ,
457+ ' - [x] Second checkbox item' ,
458+ ' - [x] Nested checkbox item' ,
459+ }, vim .api .nvim_buf_get_lines (0 , 3 , 9 , false ))
460+
461+ -- test for plain list item
454462 vim .fn .cursor (4 , 1 )
455463 vim .cmd ([[ exe "norm ,\<CR>"]] )
456464 assert .are .same ({
457465 ' - Regular item' ,
458466 ' - ' ,
459- ' - Second recular item' ,
467+ ' - Second regular item' ,
460468 ' - Nested item' ,
461- }, vim .api .nvim_buf_get_lines (0 , 3 , 7 , false ))
469+ ' - [x] Checkbox item' ,
470+ ' - [x] Second checkbox item' ,
471+ ' - [x] Nested checkbox item' ,
472+ }, vim .api .nvim_buf_get_lines (0 , 3 , 10 , false ))
473+
474+ -- tests for checkbox item
475+ vim .fn .cursor (8 , 7 ) -- on the opening bracket
476+ vim .cmd ([[ exe "norm ,\<CR>"]] )
477+ assert .are .same ({
478+ ' - Regular item' ,
479+ ' - ' ,
480+ ' - Second regular item' ,
481+ ' - Nested item' ,
482+ ' - [x] Checkbox item' ,
483+ ' - [ ] ' ,
484+ ' - [x] Second checkbox item' ,
485+ ' - [x] Nested checkbox item' ,
486+ }, vim .api .nvim_buf_get_lines (0 , 3 , 11 , false ))
487+ vim .fn .cursor (8 , 8 ) -- on the 'x' (a.k.a. status)
488+ vim .cmd ([[ exe "norm ,\<CR>"]] )
489+ assert .are .same ({
490+ ' - Regular item' ,
491+ ' - ' ,
492+ ' - Second regular item' ,
493+ ' - Nested item' ,
494+ ' - [x] Checkbox item' ,
495+ ' - [ ] ' ,
496+ ' - [ ] ' ,
497+ ' - [x] Second checkbox item' ,
498+ ' - [x] Nested checkbox item' ,
499+ }, vim .api .nvim_buf_get_lines (0 , 3 , 12 , false ))
462500 end )
463501
464502 it (' should add list item with blank line with Enter (org_meta_return)' , function ()
@@ -473,13 +511,13 @@ describe('Mappings', function()
473511 ' ' ,
474512 ' * TODO Test orgmode' ,
475513 ' - Regular item' ,
476- ' - Second recular item' ,
514+ ' - Second regular item' ,
477515 ' - Nested item' ,
478516 })
479517
480518 assert .are .same ({
481519 ' - Regular item' ,
482- ' - Second recular item' ,
520+ ' - Second regular item' ,
483521 ' - Nested item' ,
484522 }, vim .api .nvim_buf_get_lines (0 , 3 , 6 , false ))
485523 vim .fn .cursor (4 , 1 )
@@ -488,7 +526,7 @@ describe('Mappings', function()
488526 ' - Regular item' ,
489527 ' ' ,
490528 ' - ' ,
491- ' - Second recular item' ,
529+ ' - Second regular item' ,
492530 ' - Nested item' ,
493531 }, vim .api .nvim_buf_get_lines (0 , 3 , 8 , false ))
494532 config :extend ({
0 commit comments