Skip to content

Commit 0420978

Browse files
committed
refactor(tests): define exports same as everywhere else
1 parent 6bba08d commit 0420978

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

tests/plenary/helpers.lua

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
local OrgFile = require('orgmode.files.file')
22
local orgmode = require('orgmode')
33

4-
local function load_file(path)
5-
vim.cmd(string.format('e %s', path))
4+
local M = {}
5+
6+
---@param path string
7+
function M.load_file(path)
8+
vim.cmd.edit(path)
69
return orgmode.files:get(path)
710
end
811

9-
local function create_file(lines)
12+
---@param lines string[]
13+
function M.create_file(lines)
1014
local fname = vim.fn.tempname() .. '.org'
1115
vim.fn.writefile(lines or {}, fname)
12-
return load_file(fname)
16+
return M.load_file(fname)
1317
end
1418

19+
---@param lines string[]
20+
---@param config? table
1521
---@return OrgFile
16-
local function create_agenda_file(lines, config)
22+
function M.create_agenda_file(lines, config)
1723
local fname = vim.fn.tempname() .. '.org'
1824
vim.fn.writefile(lines or {}, fname)
1925

@@ -22,11 +28,13 @@ local function create_agenda_file(lines, config)
2228
}, config or {})
2329
local org = orgmode.setup(cfg)
2430
org:init()
25-
return load_file(fname)
31+
return M.load_file(fname)
2632
end
2733

34+
---@param lines string[]
35+
---@param filename string
2836
---@return OrgFile
29-
local function create_file_instance(lines, filename)
37+
function M.create_file_instance(lines, filename)
3038
local file = OrgFile:new({
3139
filename = filename or vim.fn.tempname() .. '.org',
3240
lines = lines,
@@ -36,9 +44,9 @@ local function create_file_instance(lines, filename)
3644
end
3745

3846
---@param fixtures {filename: string, content: string[] }[]
39-
---@param config table?
47+
---@param config? table
4048
---@return table
41-
local function create_agenda_files(fixtures, config)
49+
function M.create_agenda_files(fixtures, config)
4250
-- NOTE: content is only 1 line for 1 file
4351
local temp_fname = vim.fn.tempname()
4452
local temp_dir = vim.fn.fnamemodify(temp_fname, ':p:h')
@@ -65,10 +73,4 @@ local function create_agenda_files(fixtures, config)
6573
return files
6674
end
6775

68-
return {
69-
load_file = load_file,
70-
create_file = create_file,
71-
create_file_instance = create_file_instance,
72-
create_agenda_file = create_agenda_file,
73-
create_agenda_files = create_agenda_files,
74-
}
76+
return M

0 commit comments

Comments
 (0)