From 46534fe8b7f2514cf4d5b1e67ab638b20894c681 Mon Sep 17 00:00:00 2001 From: Shadman <13149513+shadmansaleh@users.noreply.github.com> Date: Sat, 13 Nov 2021 20:01:01 +0600 Subject: [PATCH] fix: fix flacky test (#434) --- lua/tests/minimal_init.lua | 1 + lua/tests/spec/component_spec.lua | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lua/tests/minimal_init.lua b/lua/tests/minimal_init.lua index 44cdffa..6f4b692 100644 --- a/lua/tests/minimal_init.lua +++ b/lua/tests/minimal_init.lua @@ -8,5 +8,6 @@ end vim.cmd [[ set rtp+=. set rtp+=../plenary.nvim + set rtp+=../nvim-web-devicons/ runtime plugin/plenary.vim ]] diff --git a/lua/tests/spec/component_spec.lua b/lua/tests/spec/component_spec.lua index 1697ae9..f9bdbf4 100644 --- a/lua/tests/spec/component_spec.lua +++ b/lua/tests/spec/component_spec.lua @@ -258,11 +258,19 @@ describe('Filetype component', function() end) it('does not add icon when library unavailable', function() + local old_require = _G.require + function _G.require(...) + if select(1, ...) == 'nvim-web-devicons' then + error("Test case not suppose to have web-dev-icon 👀") + end + return old_require(...) + end local opts = build_component_opts { component_separators = { left = '', right = '' }, padding = 0, } assert_component('filetype', opts, 'lua') + _G.require = old_require end) it('colors nvim-web-devicons icons', function()