summaryrefslogtreecommitdiff
path: root/lua/tests/automated
diff options
context:
space:
mode:
authorSimon Hauser <Simon-Hauser@outlook.de>2022-03-31 18:42:38 +0200
committerGitHub <noreply@github.com>2022-03-31 18:42:38 +0200
commitd38ad438f3bb4e3721b9964172c8c9d70d5d06a8 (patch)
tree8a6381b507c8c7362b740248028da73393094a65 /lua/tests/automated
parentb83d6d471135c53d4926677a62fccbc8318bef93 (diff)
fix: action replace/enhance if the replaced/enhanced action as combined (#1814)
Diffstat (limited to 'lua/tests/automated')
-rw-r--r--lua/tests/automated/action_spec.lua64
1 files changed, 64 insertions, 0 deletions
diff --git a/lua/tests/automated/action_spec.lua b/lua/tests/automated/action_spec.lua
index 634b2d7..c1dd8b3 100644
--- a/lua/tests/automated/action_spec.lua
+++ b/lua/tests/automated/action_spec.lua
@@ -282,6 +282,70 @@ describe("actions", function()
eq(3, called_count)
end)
+ it(
+ "can call replace fn even when combined before replace registered the fn (because that happens with mappings)",
+ function()
+ local a = transform_mod {
+ x = function()
+ return "x"
+ end,
+ y = function()
+ return "y"
+ end,
+ }
+
+ local called_count = 0
+ local count_inc = function()
+ called_count = called_count + 1
+ end
+
+ local x_plus_y = a.x + a.y
+ a.x:replace(function()
+ count_inc()
+ end)
+ a.y:replace(function()
+ count_inc()
+ end)
+
+ x_plus_y()
+
+ eq(2, called_count)
+ end
+ )
+
+ it(
+ "can call enhance fn even when combined before enhance registed fns (because that happens with mappings)",
+ function()
+ local a = transform_mod {
+ x = function()
+ return "x"
+ end,
+ y = function()
+ return "y"
+ end,
+ }
+
+ local called_count = 0
+ local count_inc = function()
+ called_count = called_count + 1
+ end
+
+ local x_plus_y = a.x + a.y
+ a.y:enhance {
+ pre = count_inc,
+ post = count_inc,
+ }
+
+ a.x:enhance {
+ post = count_inc,
+ }
+
+ x_plus_y()
+
+ eq(3, called_count)
+ end
+ )
+
it("clears enhance", function()
local a = transform_mod {
x = function()