#!/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" [[ "$out" == *"headless"* ]] || fail "help should say create/status are headless" [[ "$out" != *"--headed"* ]] || fail "help must not advertise --headed" 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."