package com.peachpasswords.autofill import com.peachpasswords.vault.VaultEntry import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue import org.junit.Test class RememberOfferTest { private fun entry(title: String, url: String?) = VaultEntry(id = title, title = title, url = url, createdAt = 0, modifiedAt = 0) @Test fun manual_pick_on_new_web_origin_offers_the_page_domain() { val bank = entry("Bank", "https://bank.example.com") val parsed = ParsedStructure(webDomain = "shop.other.com", originDomains = listOf("other.com")) assertEquals(listOf("other.com"), rememberOfferDomains(bank, parsed)) } @Test fun no_offer_when_origin_domain_already_covered() { val bank = entry("Bank", "https://bank.example.com") .copy(additionalUrls = listOf("https://other.com/login")) val parsed = ParsedStructure(webDomain = "other.com", originDomains = listOf("other.com")) assertTrue(rememberOfferDomains(bank, parsed).isEmpty()) } @Test fun no_offer_for_entry_without_any_domains() { val note = entry("Note", null) val parsed = ParsedStructure(webDomain = "other.com", originDomains = listOf("other.com")) assertTrue(rememberOfferDomains(note, parsed).isEmpty()) } @Test fun no_offer_when_origin_has_no_domains() { val bank = entry("Bank", "https://bank.example.com") val parsed = ParsedStructure(packageName = "com.example.app") assertTrue(rememberOfferDomains(bank, parsed).isEmpty()) } }