Skip to content

Commit

Permalink
Make separate kept_win assertion to allow update_wins assertion w…
Browse files Browse the repository at this point in the history
…ithin `changed_win`.
  • Loading branch information
rish987 committed Jul 26, 2021
1 parent 1ae1809 commit 9c6eac8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lua/tests/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,19 @@ local function closed_win(_, arguments)
return true
end

local function changed_win(state, _)
-- no nested assertion to allow for negation
local result = last_win ~= vim.api.nvim_get_current_win()
if state.mod and result then last_win = vim.api.nvim_get_current_win() end
local function changed_win(_, _)
assert.are_not.equal(last_win, vim.api.nvim_get_current_win())

return result
assert.update_wins()
return true
end

local function kept_win(_, _)
assert.are_equal(last_win, vim.api.nvim_get_current_win())

assert.update_wins()
return true
end

local function opened_infoview(_, arguments)
local this_info = arguments[1]
Expand Down Expand Up @@ -335,6 +340,7 @@ assert:register("assertion", "update_wins", update_wins)
assert:register("assertion", "closed_win", closed_win)
assert:register("assertion", "created_win", created_win)
assert:register("assertion", "changed_win", changed_win)
assert:register("assertion", "kept_win", kept_win)

-- initialize on very first nvim window (base case satisfied pretty trivially)
assert.created_win()
Expand Down

0 comments on commit 9c6eac8

Please sign in to comment.