blob: aefb371c08607fa68504301b395cf41e9a32286d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#!/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."
|