1
- local helpers = require (' tests.plenary.helpers' )
2
1
local orgmode = require (' orgmode' )
2
+ local Date = require (' orgmode.objects.date' )
3
3
4
4
describe (' Init' , function ()
5
5
local org = orgmode .setup ({
@@ -10,6 +10,7 @@ describe('Init', function()
10
10
local todo_archive_file = vim .fn .getcwd () .. ' /tests/plenary/fixtures/todo.org_archive'
11
11
local refile_file = vim .fn .getcwd () .. ' /tests/plenary/fixtures/refile.org'
12
12
local txt_file = vim .fn .getcwd () .. ' /tests/plenary/fixtures/text_notes.txt'
13
+
13
14
it (' should load and parse files from folder' , function ()
14
15
assert .is .Nil (rawget (org , ' files' ))
15
16
assert .is .Nil (rawget (org , ' agenda' ))
@@ -53,4 +54,23 @@ describe('Init', function()
53
54
-- Existing file in path not appended to paths
54
55
assert .are .same ({ vim .fn .getcwd () .. ' /tests/plenary/fixtures/*' , fname }, org .files .paths )
55
56
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 )
56
76
end )
0 commit comments