forked from pimterry/notes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bash-completion: Support spaces in note names
This also introduces a basic test-suite for the bash completion
- Loading branch information
Linus Wallgren
committed
Dec 3, 2016
1 parent
b52e0b5
commit 7b1fa74
Showing
2 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!./libs/bats/bin/bats | ||
|
||
load 'libs/bats-support/load' | ||
load 'libs/bats-assert/load' | ||
load 'helpers' | ||
|
||
setup() { | ||
setupNotesEnv | ||
source notes.bash_completion | ||
COMP_WORDS=() | ||
} | ||
|
||
teardown() { | ||
teardownNotesEnv | ||
} | ||
|
||
@test "Should list all commands" { | ||
touch $NOTES_DIRECTORY/note1.md | ||
_notes_complete_commands "" | ||
assert_equal "${COMPREPLY[0]}" 'new' | ||
assert_equal "${COMPREPLY[1]}" 'find' | ||
assert_equal "${COMPREPLY[2]}" 'grep' | ||
assert_equal "${COMPREPLY[3]}" 'open' | ||
} | ||
|
||
@test "Should show matching note when found" { | ||
touch $NOTES_DIRECTORY/note1.md | ||
_notes_complete_notes "no" | ||
assert_equal "${COMPREPLY[@]}" "note1" | ||
} | ||
|
||
@test "Should show multiple matching notes" { | ||
touch $NOTES_DIRECTORY/note1.md | ||
touch $NOTES_DIRECTORY/note2.md | ||
_notes_complete_notes "no" | ||
assert_equal "${COMPREPLY[0]}" 'note1' | ||
assert_equal "${COMPREPLY[1]}" 'note2' | ||
assert_equal 2 "${#COMPREPLY[@]}" | ||
} | ||
|
||
@test "Should show one completion for note with space" { | ||
touch "$NOTES_DIRECTORY/my note.md" | ||
_notes_complete_notes "" | ||
assert_equal "${COMPREPLY[0]}" 'my note' | ||
assert_equal 1 "${#COMPREPLY[@]}" | ||
} |