Skip to content

Commit adfd033

Browse files
committed
test(hook): cover zsh no-arg cd
1 parent 5720fda commit adfd033

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

cmd/wtp/hook_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,19 @@ func TestHookScripts_HandleEdgeCases(t *testing.T) {
121121
"echo \"Usage:",
122122
},
123123
},
124+
{
125+
name: "zsh hook supports no-arg cd",
126+
shell: "zsh",
127+
requiredLogic: []string{
128+
"if [[ -z \"$2\" ]]", // No-arg branch
129+
"target_dir=$(command wtp cd", // Uses `wtp cd` default behavior
130+
"target_dir=$(command wtp cd \"$2", // Uses explicit worktree name when present
131+
},
132+
notContains: []string{
133+
"Usage: wtp cd <worktree>",
134+
"echo \"Usage:",
135+
},
136+
},
124137
{
125138
name: "fish hook supports no-arg cd",
126139
shell: "fish",
@@ -144,6 +157,8 @@ func TestHookScripts_HandleEdgeCases(t *testing.T) {
144157
switch tt.shell {
145158
case "bash":
146159
require.NoError(t, printBashHook(&buf))
160+
case "zsh":
161+
require.NoError(t, printZshHook(&buf))
147162
case "fish":
148163
require.NoError(t, printFishHook(&buf))
149164
}

0 commit comments

Comments
 (0)