preview.nvim/spec/commands_spec.lua
Barrett Ruth 7a7c407d97
refactor: rename build to compile and watch to toggle in public API
Problem: the code used build/watch while the help file already
documented compile/toggle, creating a confusing mismatch.

Solution: rename M.build() to M.compile() and M.watch() to M.toggle()
in init.lua, update handler keys in commands.lua, and update the test
file to match.
2026-03-04 13:10:34 -05:00

52 lines
1.4 KiB
Lua

local helpers = require('spec.helpers')
describe('commands', function()
before_each(function()
helpers.reset_config()
end)
describe('setup', function()
it('creates the :Preview command', function()
require('preview.commands').setup()
local cmds = vim.api.nvim_get_commands({})
assert.is_not_nil(cmds.Preview)
end)
end)
describe('dispatch', function()
it('does not error on :Preview compile with no provider', function()
require('preview.commands').setup()
assert.has_no.errors(function()
vim.cmd('Preview compile')
end)
end)
it('does not error on :Preview stop', function()
require('preview.commands').setup()
assert.has_no.errors(function()
vim.cmd('Preview stop')
end)
end)
it('does not error on :Preview status', function()
require('preview.commands').setup()
assert.has_no.errors(function()
vim.cmd('Preview status')
end)
end)
it('does not error on :Preview open', function()
require('preview.commands').setup()
assert.has_no.errors(function()
vim.cmd('Preview open')
end)
end)
it('does not error on :Preview toggle with no provider', function()
require('preview.commands').setup()
assert.has_no.errors(function()
vim.cmd('Preview toggle')
end)
end)
end)
end)