Add keyBind tests.

This commit is contained in:
Kevin Baensch 2024-11-30 17:21:47 +01:00
parent c4918b9704
commit 5342429193
Signed by: derped
GPG key ID: C0F1D326C7626543

View file

@ -12,6 +12,12 @@ let
builder = "test"; builder = "test";
system = "test"; system = "test";
}; };
minBind = {
bind = "<leader>";
cmd = null;
cmdIsFunction = false;
opts = null;
};
in in
{ {
helpers = { 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 = { pluginWrapper = {
testShort = { testShort = {
expr = lazyUtils.helpers.pluginWrapper "test"; expr = lazyUtils.helpers.pluginWrapper "test";