fzf: Add tests
This commit is contained in:
parent
cb6bcc43e7
commit
351959fcdb
7 changed files with 193 additions and 0 deletions
59
tests/modules/programs/fzf/all-options.nix
Normal file
59
tests/modules/programs/fzf/all-options.nix
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
{
|
||||
programs.fzf = {
|
||||
enable = true;
|
||||
defaultCommand = "fd --type f";
|
||||
defaultOptions = [
|
||||
"--height 40%"
|
||||
"--border"
|
||||
];
|
||||
fileWidgetCommand = "fd --type f";
|
||||
fileWidgetOptions = [ "--preview 'head {}'" ];
|
||||
changeDirWidgetCommand = "fd --type d";
|
||||
changeDirWidgetOptions = [ "--preview 'tree -C {} | head -200'" ];
|
||||
historyWidgetOptions = [
|
||||
"--sort"
|
||||
"--exact"
|
||||
];
|
||||
colors = {
|
||||
bg = "#1e1e1e";
|
||||
};
|
||||
tmux = {
|
||||
enableShellIntegration = true;
|
||||
shellIntegrationOptions = [ "-d 40%" ];
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
# Test default options
|
||||
assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \
|
||||
'FZF_DEFAULT_COMMAND="fd --type f"'
|
||||
assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \
|
||||
'FZF_DEFAULT_OPTS="--height 40% --border --color'
|
||||
|
||||
# Test file widget
|
||||
assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \
|
||||
'FZF_CTRL_T_COMMAND="fd --type f"'
|
||||
assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \
|
||||
'FZF_CTRL_T_OPTS="--preview'
|
||||
|
||||
# Test change dir widget
|
||||
assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \
|
||||
'FZF_ALT_C_COMMAND="fd --type d"'
|
||||
assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \
|
||||
'FZF_ALT_C_OPTS="--preview'
|
||||
|
||||
# Test history widget
|
||||
assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \
|
||||
'FZF_CTRL_R_OPTS="--sort --exact"'
|
||||
|
||||
# Test tmux
|
||||
assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \
|
||||
'FZF_TMUX="1"'
|
||||
assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \
|
||||
'FZF_TMUX_OPTS="-d 40%"'
|
||||
|
||||
# Test colors are exported
|
||||
assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \
|
||||
'FZF_DEFAULT_OPTS=.*--color'
|
||||
'';
|
||||
}
|
||||
27
tests/modules/programs/fzf/bash-integration.nix
Normal file
27
tests/modules/programs/fzf/bash-integration.nix
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{ config, ... }:
|
||||
|
||||
{
|
||||
programs.fzf = {
|
||||
enable = true;
|
||||
enableBashIntegration = true;
|
||||
|
||||
package = config.lib.test.mkStubPackage {
|
||||
name = "fzf";
|
||||
version = "0.73.0";
|
||||
buildScript = ''
|
||||
mkdir -p $out/bin $out/share/fzf
|
||||
cat > $out/bin/fzf << 'EOF'
|
||||
#!/bin/sh
|
||||
echo "Stub fzf"
|
||||
EOF
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
programs.bash.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileRegex home-files/.bashrc \
|
||||
'eval.*fzf.*bash'
|
||||
'';
|
||||
}
|
||||
8
tests/modules/programs/fzf/default.nix
Normal file
8
tests/modules/programs/fzf/default.nix
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
fzf-disabled = ./disabled.nix;
|
||||
fzf-options = ./all-options.nix;
|
||||
fzf-bash-integration = ./bash-integration.nix;
|
||||
fzf-zsh-integration = ./zsh-integration.nix;
|
||||
fzf-fish-integration = ./fish-integration.nix;
|
||||
fzf-nushell-integration = ./nushell-integration.nix;
|
||||
}
|
||||
7
tests/modules/programs/fzf/disabled.nix
Normal file
7
tests/modules/programs/fzf/disabled.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
programs.fzf.enable = false;
|
||||
|
||||
nmt.script = ''
|
||||
assertPathNotExists home-files/.bashrc
|
||||
'';
|
||||
}
|
||||
28
tests/modules/programs/fzf/fish-integration.nix
Normal file
28
tests/modules/programs/fzf/fish-integration.nix
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
{ config, ... }:
|
||||
|
||||
{
|
||||
programs.fzf = {
|
||||
enable = true;
|
||||
enableFishIntegration = true;
|
||||
|
||||
package = config.lib.test.mkStubPackage {
|
||||
name = "fzf";
|
||||
version = "0.73.0";
|
||||
buildScript = ''
|
||||
mkdir -p $out/bin
|
||||
cat > $out/bin/fzf << 'EOF'
|
||||
#!/bin/sh
|
||||
echo "Stub fzf"
|
||||
EOF
|
||||
chmod +x $out/bin/fzf
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
programs.fish.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileRegex home-files/.config/fish/config.fish \
|
||||
'fzf.*--fish.*source'
|
||||
'';
|
||||
}
|
||||
37
tests/modules/programs/fzf/nushell-integration.nix
Normal file
37
tests/modules/programs/fzf/nushell-integration.nix
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
programs.fzf = {
|
||||
enable = true;
|
||||
enableNushellIntegration = true;
|
||||
|
||||
package = config.lib.test.mkStubPackage {
|
||||
name = "fzf";
|
||||
version = "0.73.0";
|
||||
buildScript = ''
|
||||
mkdir -p $out/bin
|
||||
cat > $out/bin/fzf << 'EOF'
|
||||
#!/bin/sh
|
||||
echo "Stub fzf"
|
||||
EOF
|
||||
chmod +x $out/bin/fzf
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
programs.nushell.enable = true;
|
||||
|
||||
nmt.script =
|
||||
let
|
||||
nushellConfigFile =
|
||||
if pkgs.stdenv.isDarwin && !config.xdg.enable then
|
||||
"home-files/Library/Application Support/nushell/config.nu"
|
||||
else
|
||||
"home-files/.config/nushell/config.nu";
|
||||
in
|
||||
''
|
||||
assertFileExists "${nushellConfigFile}"
|
||||
assertFileRegex "${nushellConfigFile}" \
|
||||
'source.*nushell-fzf-integration'
|
||||
'';
|
||||
}
|
||||
27
tests/modules/programs/fzf/zsh-integration.nix
Normal file
27
tests/modules/programs/fzf/zsh-integration.nix
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{ config, ... }:
|
||||
|
||||
{
|
||||
programs.fzf = {
|
||||
enable = true;
|
||||
enableZshIntegration = true;
|
||||
|
||||
package = config.lib.test.mkStubPackage {
|
||||
name = "fzf";
|
||||
version = "0.73.0";
|
||||
buildScript = ''
|
||||
mkdir -p $out/bin $out/share/fzf
|
||||
cat > $out/bin/fzf << 'EOF'
|
||||
#!/bin/sh
|
||||
echo "Stub fzf"
|
||||
EOF
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
programs.zsh.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileRegex home-files/.zshrc \
|
||||
'source.*fzf.*zsh'
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue