1- local helpers = require (' tests.plenary.helpers' )
21local orgmode = require (' orgmode' )
2+ local Date = require (' orgmode.objects.date' )
33
44describe (' Init' , function ()
55 local org = orgmode .setup ({
@@ -10,6 +10,7 @@ describe('Init', function()
1010 local todo_archive_file = vim .fn .getcwd () .. ' /tests/plenary/fixtures/todo.org_archive'
1111 local refile_file = vim .fn .getcwd () .. ' /tests/plenary/fixtures/refile.org'
1212 local txt_file = vim .fn .getcwd () .. ' /tests/plenary/fixtures/text_notes.txt'
13+
1314 it (' should load and parse files from folder' , function ()
1415 assert .is .Nil (rawget (org , ' files' ))
1516 assert .is .Nil (rawget (org , ' agenda' ))
@@ -53,4 +54,23 @@ describe('Init', function()
5354 -- Existing file in path not appended to paths
5455 assert .are .same ({ vim .fn .getcwd () .. ' /tests/plenary/fixtures/*' , fname }, org .files .paths )
5556 end )
57+
58+ it (' should load a file as org file if it has correct filetype' , function ()
59+ local fname = vim .fn .resolve (vim .fn .tempname () .. ' .txt' )
60+
61+ -- Behaves as text file
62+ vim .fn .writefile ({ ' * TODO Test' }, fname )
63+ vim .cmd (' edit ' .. fname )
64+ assert .are .same (' text' , vim .api .nvim_get_option_value (' filetype' , { buf = vim .api .nvim_get_current_buf () }))
65+ vim .cmd (' norm >>' )
66+ assert .are .same ({ ' * TODO Test' }, vim .api .nvim_buf_get_lines (0 , 0 , - 1 , false ))
67+ vim .cmd (' bw!' )
68+
69+ -- Behaves as org file
70+ vim .fn .writefile ({ ' * TODO Test' }, fname )
71+ vim .cmd (' edit ' .. fname )
72+ vim .cmd (' set filetype=org' )
73+ vim .cmd (' norm >>' )
74+ assert .are .same ({ ' ** TODO Test' }, vim .api .nvim_buf_get_lines (0 , 0 , - 1 , false ))
75+ end )
5676end )
0 commit comments