-
Notifications
You must be signed in to change notification settings - Fork 9
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
4 changed files
with
95 additions
and
11 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
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
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
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,81 @@ | ||
local paredit = require("nvim-paredit") | ||
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") | ||
|
||
it("should not wrap if cursor is whitespace", function() | ||
prepare_buffer({ | ||
content = { "(+ 2 :foo/bar)" }, | ||
cursor = { 1, 4 }, | ||
}) | ||
|
||
paredit.form.wrap_element_under_cursor("(", ")") | ||
expect({ | ||
content = { "(+ 2 :foo/bar)" }, | ||
}) | ||
end) | ||
|
||
it("should wrap namespaced keyword", function() | ||
prepare_buffer({ | ||
content = { "(+ 2 :foo/bar)" }, | ||
cursor = { 1, 7 }, | ||
}) | ||
|
||
paredit.form.wrap_element_under_cursor("(", ")") | ||
expect({ | ||
content = { "(+ 2 (:foo/bar))" }, | ||
}) | ||
end) | ||
|
||
it("should wrap namespaced keyword", function() | ||
prepare_buffer({ | ||
content = { '(+ 2 "lol")' }, | ||
cursor = { 1, 7 }, | ||
}) | ||
|
||
paredit.form.wrap_element_under_cursor("(", ")") | ||
expect({ | ||
content = { '(+ 2 ("lol"))' }, | ||
}) | ||
end) | ||
|
||
it("should wrap enclosing form", function() | ||
prepare_buffer({ | ||
content = { | ||
"(+ 2", | ||
" :foo/bar)", | ||
}, | ||
cursor = { 2, 4 }, | ||
}) | ||
|
||
paredit.form.wrap_enclosing_form_under_cursor("(", ")") | ||
expect({ | ||
content = { | ||
"((+ 2", | ||
" :foo/bar))", | ||
}, | ||
}) | ||
end) | ||
|
||
it("should wrap enclosing form if cursor is whitespace/comment", function() | ||
prepare_buffer({ | ||
content = { | ||
"(+ 2", | ||
";; foo", | ||
" :foo/bar)", | ||
}, | ||
cursor = { 2, 4 }, | ||
}) | ||
|
||
paredit.form.wrap_enclosing_form_under_cursor("(", ")") | ||
expect({ | ||
content = { | ||
"((+ 2", | ||
";; foo", | ||
" :foo/bar))", | ||
}, | ||
}) | ||
end) | ||
end) |