🧪 Set up default emoji list for tests
Inject a tiny sample emoji list into each test so no download function is engaged by default. Add tests for version display.
This commit is contained in:
parent
ceea79eb3a
commit
936f19bca6
3 changed files with 25 additions and 1 deletions
2
bemoji
2
bemoji
|
@ -40,7 +40,7 @@ usage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
version() {
|
version() {
|
||||||
echo "v${bm_version}"
|
printf "v%s" "$bm_version"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,14 @@ setup() {
|
||||||
# make bemoji executable from anywhere relative to current testfile
|
# make bemoji executable from anywhere relative to current testfile
|
||||||
TEST_DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
|
TEST_DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
|
||||||
PATH="$TEST_DIR/..:$PATH"
|
PATH="$TEST_DIR/..:$PATH"
|
||||||
|
|
||||||
|
# mock out interactive picker for static emoji return
|
||||||
|
export BEMOJI_PICKER_CMD="echo ❤️"
|
||||||
|
# set up small default set of test emoji for each test
|
||||||
|
export BEMOJI_DB_LOCATION="$BATS_TEST_TMPDIR/database"
|
||||||
|
export BEMOJI_CACHE_LOCATION="$BATS_TEST_TMPDIR/cache"
|
||||||
|
mkdir -p "$BEMOJI_DB_LOCATION" "$BEMOJI_CACHE_LOCATION"
|
||||||
|
cat "$BATS_TEST_DIRNAME/resources/test_emoji.txt" > "$BEMOJI_DB_LOCATION/emoji.txt"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "test can run script" {
|
@test "test can run script" {
|
||||||
|
@ -15,3 +23,15 @@ setup() {
|
||||||
run bemoji 3>&-
|
run bemoji 3>&-
|
||||||
assert_success
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "test receives custom picker mock output" {
|
||||||
|
run bemoji -e 3>&-
|
||||||
|
assert_output "❤️"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "-v prints correct version number" {
|
||||||
|
the_version=$(grep 'bm_version=' $(which bemoji))
|
||||||
|
|
||||||
|
run bemoji -v
|
||||||
|
assert_output "v${the_version#bm_version=}"
|
||||||
|
}
|
||||||
|
|
4
test/resources/test_emoji.txt
Normal file
4
test/resources/test_emoji.txt
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
❤️ red heart
|
||||||
|
😀 grinning face
|
||||||
|
😃 grinning face with big eyes
|
||||||
|
😄 grinning face with smiling eyes
|
Loading…
Reference in a new issue