-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add a convenience wrapper for setting up and tearing down m…
…ocks
- Loading branch information
Showing
2 changed files
with
37 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
-- SPDX-FileCopyrightText: Copyright 2025-present Greg Hurrell and contributors. | ||
-- SPDX-License-Identifier: BSD-2-Clause | ||
|
||
return function(spec) | ||
if type(spec) == 'table' then | ||
assert(_G.vim == nil) | ||
_G.vim = {} | ||
for key, value in pairs(spec) do | ||
if key == 'inspect' then | ||
if value then | ||
require('wincent.commandt.private.mocks.vim.inspect').setup() | ||
else | ||
vim.inspect = nil | ||
end | ||
elseif key == 'iter' then | ||
if value then | ||
require('wincent.commandt.private.mocks.vim.iter').setup() | ||
else | ||
vim.iter = nil | ||
end | ||
else | ||
error('unsupported key: ' .. key) | ||
end | ||
end | ||
elseif spec == false then | ||
-- Remove mock. | ||
_G.vim = nil | ||
else | ||
error('unsupported spec: ' .. type(spec)) | ||
end | ||
end |
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