preview.nvim/spec/commands_spec.lua
Barrett Ruth 3a36264f18
refactor: rename compile/toggle commands to build/watch
Problem: `compile` and `toggle` are accurate but unintuitive — `compile`
sounds academic and `toggle` says nothing about what it toggles.

Solution: rename the public API and `:Preview` subcommands to `build`
(one-shot) and `watch` (live preview). Internal compiler functions are
unchanged. No aliases for old names — clean break.
2026-03-03 16:40:51 -05:00

52 lines
1.3 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 with no provider', function()
require('preview.commands').setup()
assert.has_no.errors(function()
vim.cmd('Preview build')
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 watch with no provider', function()
require('preview.commands').setup()
assert.has_no.errors(function()
vim.cmd('Preview watch')
end)
end)
end)
end)