-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |