Skip to content

Commit

Permalink
tests: add blacklist tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tris203 committed May 6, 2024
1 parent e35f5a3 commit 574d0a6
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/precognition/blacklist_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
local utils = require("precognition.utils")
---@diagnostic disable-next-line: undefined-field
local eq = assert.are.same

describe("blacklist buffers", function()
it("a regular buffer is not blacklisted", function()
local test_buffer = vim.api.nvim_create_buf(true, false)
eq(utils.is_blacklisted_buffer(test_buffer), false)
end)

it("hidden buffer is not blacklisted", function()
local test_buffer = vim.api.nvim_create_buf(false, false)
vim.api.nvim_set_option_value("buftype", "", { buf = test_buffer })
eq(utils.is_blacklisted_buffer(test_buffer), false)
end)

it("scratch buffer is blacklisted", function()
local test_buffer = vim.api.nvim_create_buf(true, true)
eq(utils.is_blacklisted_buffer(test_buffer), true)
end)

it("hidden scratch buffer is blacklisted", function()
local test_buffer = vim.api.nvim_create_buf(false, true)
vim.api.nvim_set_option_value("buftype", "nofile", { buf = test_buffer })
eq(utils.is_blacklisted_buffer(test_buffer), true)
end)

it("nofile buffer is blacklisted", function()
local test_buffer = vim.api.nvim_create_buf(false, false)
vim.api.nvim_set_option_value("buftype", "nofile", { buf = test_buffer })
eq(utils.is_blacklisted_buffer(test_buffer), true)
end)

it("prompt buffer is blacklisted", function()
local test_buffer = vim.api.nvim_create_buf(false, false)
vim.api.nvim_set_option_value("buftype", "prompt", { buf = test_buffer })
eq(utils.is_blacklisted_buffer(test_buffer), true)
end)

it("help buffer is blacklisted", function()
local test_buffer = vim.api.nvim_create_buf(false, false)
vim.api.nvim_set_option_value("buftype", "help", { buf = test_buffer })
eq(utils.is_blacklisted_buffer(test_buffer), true)
end)

it("terminal buffer is blacklisted", function()
local test_buffer = vim.api.nvim_create_buf(false, false)
vim.api.nvim_open_term(test_buffer, {})
eq(utils.is_blacklisted_buffer(test_buffer), true)
end)
end)

0 comments on commit 574d0a6

Please sign in to comment.