//! `Site` implementation for Reddit.
//!
//! Reddit's session is cookie-based on `.reddit.com`. The `reddit_session`
//! cookie is the anchor — when it's missing or rejected, the user is
//! effectively logged out.

use async_trait::async_trait;
use tail_fin_core::Site;

pub struct RedditSite;

#[async_trait]
impl Site for RedditSite {
    fn id(&self) -> &'static str {
        "reddit"
    }

    fn display_name(&self) -> &'static str {
        "Reddit"
    }

    fn cookie_domain_patterns(&self) -> &'static [&'static str] {
        // Covers www.reddit.com, old.reddit.com, and np.reddit.com.
        &["*.reddit.com"]
    }

    fn refresh_url(&self) -> &'static str {
        "https://www.reddit.com/"
    }

    // refresh: use default (navigate + get_cookies_for_domain).
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn identity_fields() {
        let s = RedditSite;
        assert_eq!(s.id(), "reddit");
        assert_eq!(s.display_name(), "Reddit");
        assert_eq!(s.cookie_domain_patterns(), &["*.reddit.com"]);
        assert_eq!(s.refresh_url(), "https://www.reddit.com/");
    }
}
