Files
coucou/tests/SettingsSearchTests.swift
Claude e3c821b7b2 Settings search in the Coucou window
A field under Coucou in the sidebar searches every setting of Flow, the notch
and Mail, in the app's language, whatever the accents. The results replace the
pages while something is typed; a click (or Return) opens the page, scrolls to
the box and makes it glow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LJm3SRL9k3gBPaVtfPhwcT
2026-10-30 16:58:22 +01:00

31 lines
1.3 KiB
Swift

import Foundation
@main
enum SettingsSearchTests {
static func main() {
let w = SettingsSearchMatch.words
precondition(w(" Réglage SON ") == ["reglage", "son"])
precondition(w(" ").isEmpty)
let sound = (title: "Son", page: "Général", labels: ["Activer les sons", "Volume", "Ouvrir le dossier des sons"])
func m(_ q: String) -> SettingsSearchMatch? {
SettingsSearchMatch.match(w(q), title: sound.title, page: sound.page, labels: sound.labels)
}
// The box by its title or its page, whatever the accents and the case.
precondition(m("son") == .box)
precondition(m("GENERAL") == .box)
precondition(m("général son") == .box)
// A setting inside it.
precondition(m("volu") == .label("Volume"))
precondition(m("dossier") == .label("Ouvrir le dossier des sons"))
// Every word somewhere; the label with most of them.
precondition(m("ouvrir dossier son") == .label("Ouvrir le dossier des sons"))
precondition(m("volume general") == .label("Volume"))
// Not there.
precondition(m("micro") == nil)
precondition(m("volume micro") == nil, "every word must be found")
precondition(m("") == nil)
print("SettingsSearch tests: all passed")
}
}