Skip to content

Commit

Permalink
Test helper
Browse files Browse the repository at this point in the history
  • Loading branch information
grierson committed Aug 11, 2023
1 parent eb7e651 commit bee9c38
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 46 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
deps/
.build/
.clj-kondo/
.lsp/
5 changes: 3 additions & 2 deletions fnl/formedit/init.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
(local notify (autoload :nfnl.notify))
(local ts (require :nvim-treesitter.ts_utils))

; (local current-node (ts.get_node_at_cursor))
; (local cursor_pos (vim.api.nvim_win_get_cursor 0))
(local current-node (ts.get_node_at_cursor))
; Cursor {row, col} (Zero indexed)
(local cursor_pos (vim.api.nvim_win_get_cursor 0))

(fn setup []
(notify.info :hello))
Expand Down
12 changes: 12 additions & 0 deletions fnl/spec/init.fnl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(vim.opt.runtimepath:append :./.build/dependencies/plenary.nvim)
(vim.opt.runtimepath:append :./.build/dependencies/nvim-treesitter)
(vim.opt.runtimepath:append :./.build/parsers)
(vim.opt.runtimepath:append ".")
(vim.cmd.runtime {1 :plugin/plenary.vim :bang true})
(vim.cmd.runtime {1 :plugin/nvim-treesitter.lua :bang true})
(set vim.o.swapfile false)
(set vim.bo.swapfile false)
((. (require :nvim-treesitter.configs) :setup) {:ensure_installed [:clojure]
:parser_install_dir (.. (vim.fn.getcwd)
:/.build/parsers)
:sync_install true})
15 changes: 15 additions & 0 deletions fnl/spec/nfnl/cursor_spec.fnl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(local {: describe : it} (require :plenary.busted))
(local h (require :spec.nfnl.helper))

(describe "move cursor"
(fn []
(it :forward
(fn []
(h.setup {:content "(a)" :cursor [1 1]})
(vim.api.nvim_win_set_cursor 0 [1 2])
(h.expect {:content "(a)" :cursor [1 2]})))
(it :back
(fn []
(h.setup {:content "(a)" :cursor [1 2]})
(vim.api.nvim_win_set_cursor 0 [1 1])
(h.expect {:content "(a)" :cursor [1 1]})))))
12 changes: 0 additions & 12 deletions fnl/spec/nfnl/example_spec.fnl

This file was deleted.

16 changes: 16 additions & 0 deletions fnl/spec/nfnl/helper.fnl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(local assert (require :luassert.assert))
(local core (require :formedit.nfnl.core))

(fn setup [{: cursor : content}]
(vim.api.nvim_buf_set_option 0 :filetype :clojure)
(vim.api.nvim_buf_set_lines 0 0 -1 true [content])
(vim.api.nvim_win_set_cursor 0 cursor))

(fn expect [{: cursor : content}]
(when content
(assert.are.same content
(core.first (vim.api.nvim_buf_get_lines 0 0 -1 false))))
(when cursor
(assert.are.same cursor (vim.api.nvim_win_get_cursor 0))))

{: setup : expect}
2 changes: 2 additions & 0 deletions lua/formedit/init.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 8 additions & 14 deletions lua/spec/init.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions lua/spec/nfnl/cursor_spec.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions lua/spec/nfnl/example_spec.lua

This file was deleted.

26 changes: 26 additions & 0 deletions lua/spec/nfnl/helper.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bee9c38

Please sign in to comment.