@@ -909,6 +909,18 @@ describe("helpers", function()
909
909
assert .are .same (copy ._opts .args (), { " first" , " second" , " user_first" , " user_second" })
910
910
end )
911
911
912
+ it (" should keep original args if extra_args returns nil" , function ()
913
+ local copy = builtin .with ({
914
+ extra_args = function ()
915
+ return nil
916
+ end ,
917
+ })
918
+
919
+ assert .equals (type (copy ._opts .args ), " function" )
920
+ assert .are .same (copy ._opts .args (), { " first" , " second" })
921
+ assert .are .same (copy ._opts .args (), { " first" , " second" })
922
+ end )
923
+
912
924
it (" should set args to extra_args if args is nil" , function ()
913
925
local test_opts = {
914
926
method = " mockMethod" ,
@@ -925,6 +937,24 @@ describe("helpers", function()
925
937
assert .are .same (copy ._opts .args (), { " user_first" , " user_second" })
926
938
end )
927
939
940
+ it (" should set args to extra_args if args returns nil" , function ()
941
+ local test_opts = {
942
+ method = " mockMethod" ,
943
+ name = " mock-builtin" ,
944
+ filetypes = { " lua" },
945
+ generator_opts = {
946
+ args = function ()
947
+ return nil
948
+ end ,
949
+ },
950
+ }
951
+ builtin = helpers .make_builtin (test_opts )
952
+ local copy = builtin .with ({ extra_args = { " user_first" , " user_second" } })
953
+
954
+ assert .equals (type (copy ._opts .args ), " function" )
955
+ assert .are .same (copy ._opts .args (), { " user_first" , " user_second" })
956
+ end )
957
+
928
958
it (" should extend args with extra_args, but keep '-' arg last" , function ()
929
959
-- local test_opts = vim.deep_copy(opts) stack overflows
930
960
local test_opts = {
0 commit comments