Skip to content

Commit

Permalink
Don't set ft when calling prepare_buffer in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
julienvincent committed Oct 13, 2024
1 parent 733c20f commit ffc009f
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 24 deletions.
4 changes: 3 additions & 1 deletion tests/nvim-paredit/barf_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ local expect_all = require("tests.nvim-paredit.utils").expect_all
local expect = require("tests.nvim-paredit.utils").expect

describe("barfing ::", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})

describe("barfing forwards", function()
it("should barf different form types -", function()
Expand Down
4 changes: 3 additions & 1 deletion tests/nvim-paredit/cursor_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ local ts = require("nvim-treesitter.ts_utils")
local prepare_buffer = require("tests.nvim-paredit.utils").prepare_buffer

describe("cursor pos api tests", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})

it("should place cursor inside form at the beginning", function()
prepare_buffer({
Expand Down
12 changes: 9 additions & 3 deletions tests/nvim-paredit/deletions_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ local expect_all = require("tests.nvim-paredit.utils").expect_all
local expect = require("tests.nvim-paredit.utils").expect

describe("form deletions", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})

it("should delete the form", function()
prepare_buffer({
Expand Down Expand Up @@ -92,7 +94,9 @@ describe("form deletions", function()
end)

describe("form inner deletions", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})

it("should delete everything in the form", function()
prepare_buffer({
Expand Down Expand Up @@ -179,7 +183,9 @@ describe("form inner deletions", function()
end)

describe("element deletions", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})

it("should delete the element under cursor", function()
prepare_buffer({
Expand Down
7 changes: 6 additions & 1 deletion tests/nvim-paredit/element_drag_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ local expect_all = require("tests.nvim-paredit.utils").expect_all
local expect = require("tests.nvim-paredit.utils").expect

describe("element-dragging", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})
local parser = vim.treesitter.get_parser(0)
if not parser then
return error("Failed to get parser for language")
end

it("should drag the element forwards", function()
prepare_buffer({
Expand Down
4 changes: 3 additions & 1 deletion tests/nvim-paredit/element_raise_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ local prepare_buffer = require("tests.nvim-paredit.utils").prepare_buffer
local expect = require("tests.nvim-paredit.utils").expect

describe("element raising", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})

it("should raise the element", function()
prepare_buffer({
Expand Down
4 changes: 3 additions & 1 deletion tests/nvim-paredit/form_and_element_wrap_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ local prepare_buffer = require("tests.nvim-paredit.utils").prepare_buffer
local expect = require("tests.nvim-paredit.utils").expect

describe("element and form wrap", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})

it("should not wrap if cursor is whitespace", function()
prepare_buffer({
Expand Down
7 changes: 6 additions & 1 deletion tests/nvim-paredit/form_drag_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ local expect_all = require("tests.nvim-paredit.utils").expect_all
local expect = require("tests.nvim-paredit.utils").expect

describe("form-dragging", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})
local parser = vim.treesitter.get_parser(0)
if not parser then
return error("Failed to get parser for language")
end

it("should drag the form forwards", function()
expect_all(paredit.drag_form_forwards, {
Expand Down
4 changes: 3 additions & 1 deletion tests/nvim-paredit/form_raise_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ local expect_all = require("tests.nvim-paredit.utils").expect_all
local expect = require("tests.nvim-paredit.utils").expect

describe("form raising", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})

it("should raise the form", function()
expect_all(paredit.raise_form, {
Expand Down
4 changes: 3 additions & 1 deletion tests/nvim-paredit/form_unwrap_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ local prepare_buffer = require("tests.nvim-paredit.utils").prepare_buffer
local expect = require("tests.nvim-paredit.utils").expect

describe("form uwrap (e.g. splice)", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})
local unwrap = paredit.unwrap

it("should uwrap list under cursor", function()
Expand Down
4 changes: 3 additions & 1 deletion tests/nvim-paredit/indentation_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ local opts = vim.tbl_deep_extend("force", defaults.defaults, {
})

describe("forward slurping indentation", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})
local function slurp_forwards()
paredit.slurp_forwards(opts)
end
Expand Down
8 changes: 8 additions & 0 deletions tests/nvim-paredit/operator_motion_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ local defaults = require("nvim-paredit.defaults")

describe("motions with operator pending", function()
before_each(function()
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})

keybindings.setup_keybindings({
keys = defaults.default_keys,
})
Expand Down Expand Up @@ -152,6 +156,10 @@ end)

describe("motions with operator pending and v:count", function()
before_each(function()
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})

keybindings.setup_keybindings({
keys = defaults.default_keys,
})
Expand Down
8 changes: 6 additions & 2 deletions tests/nvim-paredit/pair_drag_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ local expect_all = require("tests.nvim-paredit.utils").expect_all
local expect = require("tests.nvim-paredit.utils").expect

describe("paired-element-auto-dragging", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})
it("should drag map pairs forward", function()
prepare_buffer({
content = "{:a 1 :b 2}",
Expand Down Expand Up @@ -70,7 +72,9 @@ describe("paired-element-auto-dragging", function()
end)

describe("paired-element-dragging", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})
it("should drag vector elements forwards", function()
prepare_buffer({
content = "'[a b c d]",
Expand Down
14 changes: 12 additions & 2 deletions tests/nvim-paredit/slurp_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ local expect_all = require("tests.nvim-paredit.utils").expect_all
local expect = require("tests.nvim-paredit.utils").expect

describe("slurping backward", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})
local parser = vim.treesitter.get_parser(0)
if not parser then
return error("Failed to get parser for language")
end

it("should slurp different form types", function()
expect_all(paredit.slurp_backwards, {
Expand Down Expand Up @@ -125,8 +130,13 @@ describe("slurping backward", function()
end)

describe("slurping forward", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})
local parser = vim.treesitter.get_parser(0)
if not parser then
return error("Failed to get parser for language")
end

it("should slurp forward different form types", function()
expect_all(paredit.slurp_forwards, {
Expand Down
24 changes: 18 additions & 6 deletions tests/nvim-paredit/text_object_selections_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ local expect = require("tests.nvim-paredit.utils").expect
local utils = require("tests.nvim-paredit.utils")

describe("form deletions", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})

before_each(function()
keybindings.setup_keybindings({
Expand Down Expand Up @@ -101,7 +103,9 @@ describe("form deletions", function()
end)

describe("top level form deletions", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})

before_each(function()
keybindings.setup_keybindings({
Expand Down Expand Up @@ -135,7 +139,9 @@ describe("top level form deletions", function()
end)

describe("form selections", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})

before_each(function()
keybindings.setup_keybindings({
Expand Down Expand Up @@ -163,7 +169,9 @@ describe("form selections", function()
end)

describe("top form selections", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})

before_each(function()
keybindings.setup_keybindings({
Expand Down Expand Up @@ -191,7 +199,9 @@ describe("top form selections", function()
end)

describe("element deletions", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})

before_each(function()
keybindings.setup_keybindings({
Expand All @@ -213,7 +223,9 @@ describe("element deletions", function()
end)

describe("element selections", function()
vim.api.nvim_buf_set_option(0, "filetype", "clojure")
vim.api.nvim_set_option_value("filetype", "clojure", {
buf = 0,
})

before_each(function()
keybindings.setup_keybindings({
Expand Down
2 changes: 0 additions & 2 deletions tests/nvim-paredit/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ function M.feedkeys(keys)
end

function M.prepare_buffer(params)
vim.api.nvim_buf_set_option(0, "filetype", "clojure")

local content = params.content
if type(content) == "string" then
content = { content }
Expand Down

0 comments on commit ffc009f

Please sign in to comment.