Skip to content

Commit

Permalink
Add <title> tests to helpers-selector-resolve-path.bats.
Browse files Browse the repository at this point in the history
  • Loading branch information
xwmx committed Oct 9, 2024
1 parent 3a1d1a7 commit 1a70d5d
Showing 1 changed file with 66 additions and 1 deletion.
67 changes: 66 additions & 1 deletion test/helpers-selector-resolve-path.bats
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ load test_helper
[[ -z "${output:-}" ]]
}

# resolve paths ###############################################################
# <id> ########################################################################

@test "'_selector_resolve_path()' resolves selector with root-level id file path." {
{
Expand Down Expand Up @@ -126,3 +126,68 @@ load test_helper
[[ "${status}" -eq 0 ]]
[[ "${output}" == "${NB_DIR}/home/Example Folder/Example File.md" ]]
}

# <title> #####################################################################

@test "'_selector_resolve_path()' resolves selector with root-level title file path." {
{
"${_NB}" init
"${_NB}" add "A Folder" --type folder
"${_NB}" add "Example File.md" \
--content "# Example Title"

[[ -f "${NB_DIR}/home/Example File.md" ]]

[[ -d "${NB_DIR}/home/A Folder" ]]
}

run "${_NB}" helpers selector_resolve_path "Example Title"

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

[[ "${status}" -eq 0 ]]
[[ "${output}" == "Example File.md" ]]

run "${_NB}" helpers selector_resolve_path 2 --full

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

[[ "${status}" -eq 0 ]]
[[ "${output}" == "${NB_DIR}/home/Example File.md" ]]
}

@test "'_selector_resolve_path()' resolves selector with first-level folder id file path and title." {
{
"${_NB}" init
"${_NB}" add "A Folder" --type folder
"${_NB}" add "Example Folder/A Nested Folder" --type folder

"${_NB}" add "Example Folder/Example File.md" \
--content "# Example Title"

[[ -f "${NB_DIR}/home/Example Folder/Example File.md" ]]

[[ -d "${NB_DIR}/home/A Folder" ]]
[[ -d "${NB_DIR}/home/Example Folder" ]]
[[ -d "${NB_DIR}/home/Example Folder/A Nested Folder" ]]
}

run "${_NB}" helpers selector_resolve_path "2/Example Title"

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

[[ "${status}" -eq 0 ]]
[[ "${output}" == "Example Folder/Example File.md" ]]


run "${_NB}" helpers selector_resolve_path "2/Example Title" --full

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

[[ "${status}" -eq 0 ]]
[[ "${output}" == "${NB_DIR}/home/Example Folder/Example File.md" ]]
}

0 comments on commit 1a70d5d

Please sign in to comment.