Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Breaking changes: YYYY/MM/DD.md as default <name> and list notes displays the full path relative to $JOT_DIR without the .md extension.
- Loading branch information
Showing
4 changed files
with
93 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
language: shell | ||
|
||
script: | ||
- bash -c 'shellcheck jot' | ||
- shellcheck jot && bats test.bats |
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,69 @@ | ||
#!/usr/bin/env bats | ||
|
||
# Local directory relative to PWD | ||
export JOT_DIR=./.tmp | ||
|
||
# Don't open interactively—touching is fine | ||
export EDITOR=touch | ||
|
||
# Stub out to use local `jot` | ||
jot() { | ||
./jot "${@}" | ||
} | ||
|
||
setup() { | ||
mkdir -p "${JOT_DIR}" | ||
} | ||
|
||
teardown() { | ||
rm -rf "${JOT_DIR}" | ||
} | ||
|
||
@test "jot --help prints usage & exits cleanly" { | ||
run jot --help | ||
[[ "${lines[0]}" == "Usage:" ]] | ||
[[ "${status}" == 0 ]] | ||
} | ||
|
||
@test "jot creates \$JOT_DIR if not exist" { | ||
rm -rf "${JOT_DIR}" | ||
[[ ! -d "${JOT_DIR}" ]] | ||
run jot --help | ||
[[ -d "${JOT_DIR}" ]] | ||
[[ "${status}" == 0 ]] | ||
} | ||
|
||
@test "jot no args makes a note from today" { | ||
today="$(date +%Y/%m/%d)" | ||
run jot | ||
[[ -f "${JOT_DIR}/${today}.md" ]] | ||
[[ "${status}" == 0 ]] | ||
} | ||
|
||
@test "jot --list with single note works" { | ||
run jot --list | ||
[[ "${output}" == "${today}" ]] | ||
[[ "${status}" == 0 ]] | ||
} | ||
|
||
@test "jot with simple note name works" { | ||
testnote1="testnote" | ||
run jot "${testnote1}" | ||
[[ -f "${JOT_DIR}/${testnote1}.md" ]] | ||
[[ "${status}" == 0 ]] | ||
} | ||
|
||
@test "jot with more complex note name works" { | ||
testnote2="directory/containing/some/testnote" | ||
run jot "${testnote2}" | ||
[[ -f "${JOT_DIR}/${testnote2}.md" ]] | ||
[[ "${status}" == 0 ]] | ||
} | ||
|
||
@test "jot --list with multiple notes works" { | ||
run jot --list | ||
[[ "${lines[0]}" == "${today}" ]] | ||
[[ "${lines[1]}" == "${testnote1}" ]] | ||
[[ "${lines[2]}" == "${testnote2}" ]] | ||
[[ "${status}" == 0 ]] | ||
} |