Skip to content
Discussion options

You must be logged in to vote

Yes, unfortunately, vim.fn.confirm() does tend to behave like this. I am not sure why, but mocking the method works pretty good here. This is what I use for 'mini.files' testing. It can then be used before invoking action that would require confirm (like this). Then validate arguments with which it was called (something like this).

The same approach is used in Neovim itself for vim.pack testing.

So here it would be something like this:

T["confirm"] = function()
  child.lua_notify [[M.run()]]
  child.type_keys("tester.txt")
  mock_confirm(1)
  child.type_keys("<CR>")

  eq(child.cmd_capture("messages"), '')
end

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@elanmed
Comment options

Answer selected by echasnovski
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested mini.test
2 participants