diff options
Diffstat (limited to 'infra/libkookie/home-manager/tests/modules/programs/vscode/keybindings.nix')
-rw-r--r-- | infra/libkookie/home-manager/tests/modules/programs/vscode/keybindings.nix | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/infra/libkookie/home-manager/tests/modules/programs/vscode/keybindings.nix b/infra/libkookie/home-manager/tests/modules/programs/vscode/keybindings.nix new file mode 100644 index 000000000000..d1ab38d3b059 --- /dev/null +++ b/infra/libkookie/home-manager/tests/modules/programs/vscode/keybindings.nix @@ -0,0 +1,71 @@ +# Test that keybdinings.json is created correctly. +{ config, lib, pkgs, ... }: + +with lib; + +let + bindings = [ + { + key = "ctrl+c"; + command = "editor.action.clipboardCopyAction"; + when = "textInputFocus && false"; + } + { + key = "ctrl+c"; + command = "deleteFile"; + when = ""; + } + { + key = "d"; + command = "deleteFile"; + when = "explorerViewletVisible"; + } + ]; + + targetPath = if pkgs.stdenv.hostPlatform.isDarwin then + "Library/Application Support/Code/User/keybindings.json" + else + ".config/Code/User/keybindings.json"; + + expectedJson = pkgs.writeText "expected.json" '' + [ + { + "command": "editor.action.clipboardCopyAction", + "key": "ctrl+c", + "when": "textInputFocus && false" + }, + { + "command": "deleteFile", + "key": "ctrl+c", + "when": "" + }, + { + "command": "deleteFile", + "key": "d", + "when": "explorerViewletVisible" + } + ] + ''; +in { + config = { + programs.vscode = { + enable = true; + keybindings = bindings; + }; + + nixpkgs.overlays = [ + (self: super: { + vscode = pkgs.runCommandLocal "vscode" { pname = "vscode"; } '' + mkdir -p $out/bin + touch $out/bin/code + chmod +x $out/bin/code; + ''; + }) + ]; + + nmt.script = '' + assertFileExists "home-files/${targetPath}" + assertFileContent "home-files/${targetPath}" "${expectedJson}" + ''; + }; +} |