mirror of
https://github.com/HiPhish/rainbow-delimiters.nvim.git
synced 2024-09-16 14:24:05 +02:00
Translate selective activation test to Busted
This commit is contained in:
parent
7c171bbeff
commit
bbe08e16ae
3 changed files with 49 additions and 17 deletions
4
makefile
4
makefile
|
@ -28,7 +28,7 @@
|
|||
check: unit-test e2e-test
|
||||
|
||||
unit-test:
|
||||
eval $$(luarocks path --lua-version 5.1 --bin) && busted --run unit
|
||||
@eval $$(luarocks path --lua-version 5.1 --bin) && busted --run unit
|
||||
|
||||
e2e-test:
|
||||
eval $$(luarocks path --lua-version 5.1 --bin) && busted --run e2e
|
||||
@eval $$(luarocks path --lua-version 5.1 --bin) && busted --run e2e
|
||||
|
|
47
test/e2e/selective-activation.lua
Normal file
47
test/e2e/selective-activation.lua
Normal file
|
@ -0,0 +1,47 @@
|
|||
local rpcrequest = vim.fn.rpcrequest
|
||||
|
||||
local jobopts = {
|
||||
rpc = true,
|
||||
width = 80,
|
||||
height = 24,
|
||||
}
|
||||
|
||||
local exec_lua = 'nvim_exec_lua'
|
||||
local buf_set_lines = 'nvim_buf_set_lines'
|
||||
|
||||
describe('We can disable rainbow delimiters for certain languages', function()
|
||||
local nvim
|
||||
|
||||
local function request(method, ...)
|
||||
return rpcrequest(nvim, method, ...)
|
||||
end
|
||||
|
||||
before_each(function()
|
||||
-- Start the remote Neovim process. The `--embed` flag lets us control
|
||||
-- Neovim through RPC, the `--headless` flag tells it not to wait for a
|
||||
-- UI to attach and start loading plugins and configuration immediately
|
||||
nvim = vim.fn.jobstart({'nvim', '--embed', '--headless'}, jobopts)
|
||||
end)
|
||||
|
||||
after_each(function()
|
||||
vim.fn.jobstop(nvim)
|
||||
end)
|
||||
|
||||
it('Does not run for a blacklisted language', function()
|
||||
request(exec_lua, 'the_strategy = require("rainbow-delimiters.strategy.track")(require("rainbow-delimiters.strategy.no-op"))', {})
|
||||
request(exec_lua, 'vim.g.rainbow_delimiters = {blacklist = {"lua"}, strategy = {[""] = the_strategy}}', {})
|
||||
request(buf_set_lines, 0, 0, -1, true, {'print "Hello world"', '-- vim:ft=lua'})
|
||||
request('nvim_command', 'filetype detect')
|
||||
local attachments = request(exec_lua, 'return the_strategy.attachments[1]', {})
|
||||
assert.is.equal(0, attachments)
|
||||
end)
|
||||
|
||||
it('Runs for a whitelisted language', function()
|
||||
request(exec_lua, 'the_strategy = require("rainbow-delimiters.strategy.track")(require("rainbow-delimiters.strategy.no-op"))', {})
|
||||
request(exec_lua, 'vim.g.rainbow_delimiters = {whitelist = {"lua"}, strategy = {[""] = the_strategy}}', {})
|
||||
request(buf_set_lines, 0, 0, -1, true, {'print "Hello world"', '-- vim:ft=lua'})
|
||||
request('nvim_command', 'filetype detect')
|
||||
local attachments = request(exec_lua, 'return the_strategy.attachments[1]', {})
|
||||
assert.is.equal(1, attachments)
|
||||
end)
|
||||
end)
|
|
@ -1,15 +0,0 @@
|
|||
# We can disable rainbow delimiters for certain languages
|
||||
|
||||
Execute lua (Set up the plugin):
|
||||
the_strategy = require('rainbow-delimiters.strategy.track')(require('rainbow-delimiters.strategy.no-op'))
|
||||
vim.g.rainbow_delimiters = {blacklist = {'lua'}, strategy = {[''] = the_strategy}}
|
||||
|
||||
Given lua (A Lua buffer):
|
||||
'test'
|
||||
|
||||
Execute (Do Nothing):
|
||||
|
||||
Then (Not attached to the Lua buffer):
|
||||
AssertEqual 0, luaeval('the_strategy.attachments[1]')
|
||||
|
||||
# vim:tw=79:ts=2:sw=2:et:
|
Loading…
Reference in a new issue