diff --git a/tests/lazyUtils.nix b/tests/lazyUtils.nix index 1ca9e9f..07e4f44 100644 --- a/tests/lazyUtils.nix +++ b/tests/lazyUtils.nix @@ -12,6 +12,12 @@ let builder = "test"; system = "test"; }; + minBind = { + bind = ""; + cmd = null; + cmdIsFunction = false; + opts = null; + }; in { helpers = { @@ -41,7 +47,66 @@ in }; }; }; - getKey = { }; + getKey = { + testBind = { + expr = lazyUtils.helpers.getKey minBind; + expected = [ + minBind.bind + ]; + }; + testCmd = { + expr = lazyUtils.helpers.getKey (minBind // { cmd = "testCmd"; }); + expected = [ + minBind.bind + "testCmd" + ]; + }; + testFnNoCmd = { + expr = lazyUtils.helpers.getKey (minBind // { cmdIsFunction = true; }); + expected = [ + minBind.bind + ]; + }; + testFn = { + expr = + let + result = lazyUtils.helpers.getKey ( + minBind + // { + cmd = "testCmd"; + cmdIsFunction = true; + } + ); + in + assert builtins.isFunction (builtins.elemAt result 1); + map (val: if builtins.isFunction val then val null else val) result; + expected = [ + minBind.bind + "testCmd" + ]; + }; + testOpts = { + expr = lazyUtils.helpers.getKey ( + minBind + // { + opts = { + description = "A test keybind."; + }; + } + ); + expected = [ + minBind.bind + { + __unpack = true; + description = "A test keybind."; + } + ]; + }; + testInvalid = { + expr = lazyUtils.helpers.getKey (minBind // { cmdIsFunction = null; }); + expectedError.type = "AssertionError"; + }; + }; pluginWrapper = { testShort = { expr = lazyUtils.helpers.pluginWrapper "test";