diff options
| author | TJ DeVries <devries.timothyj@gmail.com> | 2020-12-23 13:31:05 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-23 13:31:05 -0500 |
| commit | 049602a2c5f436fd7758fe5dd2fd1fcea696b83b (patch) | |
| tree | df8297e7904e2f30bfe1a33587269a6794ddb962 /lua/telescope/pickers/_test_helpers.lua | |
| parent | 4850c6df6d04aa6b98912b1dac9def713b1eda44 (diff) | |
ci: more tests (#359)
* more tests
* lint
Diffstat (limited to 'lua/telescope/pickers/_test_helpers.lua')
| -rw-r--r-- | lua/telescope/pickers/_test_helpers.lua | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lua/telescope/pickers/_test_helpers.lua b/lua/telescope/pickers/_test_helpers.lua new file mode 100644 index 0000000..a430fae --- /dev/null +++ b/lua/telescope/pickers/_test_helpers.lua @@ -0,0 +1,50 @@ +local test_helpers = {} + +test_helpers.get_picker = function() + local state = require('telescope.state') + return state.get_status(vim.api.nvim_get_current_buf()).picker +end + +test_helpers.get_results_bufnr = function() + local state = require('telescope.state') + return state.get_status(vim.api.nvim_get_current_buf()).results_bufnr +end + +test_helpers.get_file = function() + return vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), ":t") +end + +test_helpers.get_prompt = function() + return vim.api.nvim_buf_get_lines(0, 0, -1, false)[1] +end + +test_helpers.get_results = function() + return vim.api.nvim_buf_get_lines(test_helpers.get_results_bufnr(), 0, -1, false) +end + +test_helpers.get_last_result = function() + local results = test_helpers.get_results() + return results[#results] +end + +test_helpers.get_selection = function() + local state = require('telescope.state') + return state.get_global_key('selected_entry') +end + +test_helpers.get_selection_value = function() + return test_helpers.get_selection().value +end + +test_helpers.make_globals = function() + GetFile = test_helpers.get_file -- luacheck: globals GetFile + GetPrompt = test_helpers.get_prompt -- luacheck: globals GetPrompt + + GetResults = test_helpers.get_results -- luacheck: globals GetResults + GetLastResult = test_helpers.get_last_result -- luacheck: globals GetLastResult + + GetSelection = test_helpers.get_selection -- luacheck: globals GetSelection + GetSelectionValue = test_helpers.get_selection_value -- luacheck: globals GetSelectionValue +end + +return test_helpers |
