Skip to content

Commit 5a6eb9c

Browse files
committed
Add tests for shorthand aliases
1 parent e75664a commit 5a6eb9c

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

test/test-find.bats

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ notes="./notes"
3232
assert_line "note2.md"
3333
}
3434

35+
@test "Should find notes when using the find shorthand alias" {
36+
touch $NOTES_DIRECTORY/note.md
37+
38+
run $notes f
39+
assert_success
40+
assert_line "note.md"
41+
}
42+
3543
@test "Should show matching notes only if a pattern is provided to find" {
3644
touch $NOTES_DIRECTORY/match-note1.md
3745
touch $NOTES_DIRECTORY/hide-note2.md

test/test-grep.bats

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ notes="./notes"
3232
refute_line "non-matching-note.md"
3333
}
3434

35+
@test "Should grep notes when using the grep shorthand alias" {
36+
echo "my-pattern" > $NOTES_DIRECTORY/matching-note.md
37+
38+
run $notes g my-pattern
39+
40+
assert_success
41+
assert_line "matching-note.md"
42+
}
43+
3544
@test "Should grep case-insensitively" {
3645
echo "LETTERS" > $NOTES_DIRECTORY/matching-note.md
3746

test/test-new.bats

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ notes="./notes"
2222
assert_exists "$NOTES_DIRECTORY/note.md"
2323
}
2424

25+
@test "Should create new notes when using the shorthand alias" {
26+
run $notes n note
27+
28+
assert_success
29+
assert_exists "$NOTES_DIRECTORY/note.md"
30+
}
31+
2532
@test "Should create new notes within subfolders" {
2633
run $notes new subfolder/note
2734

test/test-open.bats

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ notes="./notes"
5454
assert_output "Editing $NOTES_DIRECTORY/note.md"
5555
}
5656

57+
@test "Opens a file passed by pipe when using the shorthand open alias" {
58+
touch $NOTES_DIRECTORY/note.md
59+
60+
run bash -c "$notes find | $notes o"
61+
62+
assert_success
63+
assert_output "Editing $NOTES_DIRECTORY/note.md"
64+
}
65+
5766
@test "Opens multiple files passed by pipe from find" {
5867
touch $NOTES_DIRECTORY/note.md
5968
touch $NOTES_DIRECTORY/note2.md

0 commit comments

Comments
 (0)