summaryrefslogtreecommitdiff
path: root/tests/cli.test.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cli.test.sh')
-rwxr-xr-xtests/cli.test.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/cli.test.sh b/tests/cli.test.sh
new file mode 100755
index 0000000..2694938
--- /dev/null
+++ b/tests/cli.test.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+# Smoke tests for icloud-note CLI (no Apple login / network create required).
+set -euo pipefail
+
+ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+CLI=(node "$ROOT/scripts/icloud-note.mjs")
+
+fail() { echo "FAIL: $*" >&2; exit 1; }
+pass() { echo "ok: $*"; }
+
+out="$("${CLI[@]}" help 2>&1)" || fail "help exited non-zero"
+[[ "$out" == *"icloud-note create"* ]] || fail "help missing create usage"
+pass "help"
+
+set +e
+err="$("${CLI[@]}" nosuchcmd 2>&1)"
+code=$?
+set -e
+[[ "$code" -ne 0 ]] || fail "unknown command should fail"
+[[ "$err" == *"Unknown command"* ]] || fail "unknown command message"
+pass "unknown command"
+
+set +e
+err="$("${CLI[@]}" create 2>&1)"
+code=$?
+set -e
+[[ "$code" -ne 0 ]] || fail "create without content should fail"
+[[ "$err" == *"Provide --title"* ]] || fail "create empty message"
+pass "create requires content"
+
+echo "All cli tests passed."