44 lines
1.5 KiB
Nim
44 lines
1.5 KiB
Nim
## test_notifications.nim
|
|
## ======================
|
|
## Tests unitaires de la rotation des rappels santé (logique pure). Aucun
|
|
## appel Win32 : on ne teste que nextHealthReminder.
|
|
|
|
import std/unittest
|
|
import ../src/notifications
|
|
import ../src/config
|
|
|
|
suite "health reminder rotation":
|
|
test "does not repeat the same reminder twice in a row":
|
|
let cfg = defaultConfig()
|
|
let a = nextHealthReminder(cfg)
|
|
let b = nextHealthReminder(cfg)
|
|
check a.len > 0
|
|
check b.len > 0
|
|
check a != b
|
|
|
|
test "a single enabled reminder is always returned":
|
|
var cfg = defaultConfig()
|
|
for i in 0 ..< cfg.healthReminders.len:
|
|
cfg.healthReminders[i].enabled = (i == 0)
|
|
check nextHealthReminder(cfg) == "Lève-toi et marche 2 minutes"
|
|
check nextHealthReminder(cfg) == "Lève-toi et marche 2 minutes"
|
|
|
|
test "returns empty string when nothing is enabled":
|
|
var cfg = defaultConfig()
|
|
for i in 0 ..< cfg.healthReminders.len:
|
|
cfg.healthReminders[i].enabled = false
|
|
check nextHealthReminder(cfg) == ""
|
|
|
|
test "skips disabled reminders":
|
|
var cfg = defaultConfig()
|
|
for i in 0 ..< cfg.healthReminders.len:
|
|
cfg.healthReminders[i].enabled = (i == 2)
|
|
check nextHealthReminder(cfg) == cfg.healthReminders[2].text
|
|
|
|
test "custom reminder text is returned verbatim":
|
|
var cfg = defaultConfig()
|
|
for i in 0 ..< cfg.healthReminders.len:
|
|
cfg.healthReminders[i].enabled = false
|
|
cfg.healthReminders.add HealthReminder(text: "Médite 5 minutes", enabled: true)
|
|
check nextHealthReminder(cfg) == "Médite 5 minutes"
|