Skip to content

Commit

Permalink
Improve move prompt.
Browse files Browse the repository at this point in the history
  • Loading branch information
xwmx committed Jan 24, 2022
1 parent 2c8dbc6 commit 8236dad
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nb
Original file line number Diff line number Diff line change
Expand Up @@ -14433,7 +14433,7 @@ _move() {
break
;;
*)
printf "Exiting...\\n"
printf "Exiting%s\\n" "$(_color_dim "...")"
exit 0
;;
esac
Expand Down
40 changes: 40 additions & 0 deletions test/move.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,46 @@

load test_helper

# prompt ######################################################################

@test "'move' with non-affirmative prompt response exits without moving note." {
{
"${_NB}" init
"${_NB}" add "example.md" --content "Example content."
"${_NB}" notebooks add "destination"

_files=($(ls "${NB_DIR}/home/")) && _filename="${_files[0]}"
}

run "${_NB}" move 1 destination: <<< "n${_NEWLINE}"

printf "\${status}: '%s'\\n" "${status}"
printf "\${output}: '%s'\\n" "${output}"

# Exits with status 0:

[[ ${status} -eq 0 ]]

# Does not file:

[[ -e "${NB_DIR}/home/example.md" ]]
[[ ! -e "${NB_DIR}/destination/example.md" ]]

# Does not create git commit:

cd "${NB_DIR}/home" || return 1
while [[ -n "$(git status --porcelain)" ]]
do
sleep 1
done
git log | grep -v -q '\[nb\] Delete'

# Prints output:

[[ "${output}" =~ Moving ]]
[[ "${output}" =~ Exiting.*\.\.\. ]]
}

# no argument #################################################################

@test "'move' with no arguments exits with status 1." {
Expand Down

0 comments on commit 8236dad

Please sign in to comment.