:- use_module('../prolog/sms_otp_parse').
:- use_module(library(plunit)).

:- begin_tests(sms_otp_parse).

test(google)   :- otp_code("G-482913 is your Google verification code.", '482913').
test(split)    :- otp_code("[Monzo] Code: 482 913. Expires in 10 minutes", '482913').
test(hyphen)   :- otp_code("Your login code is 482-913", '482913').
test(phone)    :- otp_code("Call 07700 900123 if this wasn't you. Your code: 5521", '5521').
test(intl)     :- otp_code("From +447700900123: PIN 7731", '7731').
test(price)    :- otp_code("You paid £1250.00. OTP 660421", '660421').
test(year)     :- otp_code("2026 offer! Your verification code is 1984", '1984').
test(date)     :- otp_code("Login on 23-11-2026 at 14:05. Code 30412", '30412').
test(percent, fail) :- otp_code("Save 2500% today", _).
test(none, fail)    :- otp_code("Hello there", _).
test(service_bracket) :- otp_service("[Telegram] Code 55213", 'Telegram').
test(service_colon)   :- otp_service("Revolut: 112233 is your code", 'Revolut').
test(service_your)    :- otp_service("123456 is your Discord verification code", 'Discord').
test(exp_min)  :- otp_expiry_minutes("Valid for 15 minutes", 15).
test(exp_hour) :- otp_expiry_minutes("Expires in 1 hour", 60).
test(exp_sec)  :- otp_expiry_minutes("valid for 90 seconds", 2).
test(hash)     :- sms_retriever_hash("<#> 4829 is your code\nFA+9qCX9VSu", 'FA+9qCX9VSu').
test(msg)      :- otp_message("<#> Uber: 4829 is your code. Expires in 5 min\nFA+9qCX9VSu", D),
                  D == otp{code:'4829', service:'Uber', expiry_minutes:5, retriever_hash:'FA+9qCX9VSu'}.

:- end_tests(sms_otp_parse).
