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.
- Loading branch information
1 parent
d98c2ba
commit 00f49f9
Showing
4 changed files
with
99 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[*.bats] | ||
indent_size = 2 |
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
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,70 @@ | ||
#!./libs/bats/bin/bats | ||
|
||
load 'libs/bats-support/load' | ||
load 'libs/bats-assert/load' | ||
load 'helpers' | ||
|
||
setup() { | ||
setupNotesEnv | ||
} | ||
|
||
teardown() { | ||
teardownNotesEnv | ||
} | ||
|
||
notes="./notes" | ||
|
||
@test "Should output nothing and return non-zero if there are no notes to list" { | ||
run $notes ls | ||
|
||
assert_failure | ||
echo $output | ||
assert_equal $(echo $output | wc -w) 0 | ||
} | ||
|
||
@test "Should list all notes in notes directory if no pattern is provided to find" { | ||
touch $NOTES_DIRECTORY/note1.md | ||
touch $NOTES_DIRECTORY/note2.md | ||
|
||
run $notes ls | ||
assert_success | ||
assert_line "note1.md" | ||
assert_line "note2.md" | ||
} | ||
|
||
@test "Should list subdirectories with trailing slash" { | ||
touch $NOTES_DIRECTORY/match-note1.md | ||
mkdir $NOTES_DIRECTORY/match-dir | ||
|
||
run $notes ls | ||
|
||
assert_success | ||
assert_line "match-note1.md" | ||
assert_line "match-dir/" | ||
} | ||
|
||
@test "Should not list contents of subdirectories without pattern" { | ||
touch $NOTES_DIRECTORY/match-note1.md | ||
mkdir $NOTES_DIRECTORY/match-dir | ||
touch $NOTES_DIRECTORY/match-dir/hide-note.md | ||
|
||
run $notes ls | ||
|
||
assert_success | ||
assert_line "match-note1.md" | ||
assert_line "match-dir/" | ||
refute_line "hide-note.md" | ||
} | ||
|
||
@test "Should list contents of subdirectory given in pattern" { | ||
touch $NOTES_DIRECTORY/hide-note.md | ||
mkdir $NOTES_DIRECTORY/match-dir | ||
touch $NOTES_DIRECTORY/match-dir/match-note1.md | ||
|
||
run $notes ls match-dir | ||
|
||
assert_success | ||
refute_line "hide-note.md" | ||
refute_line "match-dir/" | ||
assert_line "match-note1.md" | ||
} |