RememberOfferTest.kt

1.5 KB · raw

1package com.peachpasswords.autofill23import com.peachpasswords.vault.VaultEntry4import org.junit.Assert.assertEquals5import org.junit.Assert.assertTrue6import org.junit.Test78class RememberOfferTest {9    private fun entry(title: String, url: String?) =10        VaultEntry(id = title, title = title, url = url, createdAt = 0, modifiedAt = 0)1112    @Test fun manual_pick_on_new_web_origin_offers_the_page_domain() {13        val bank = entry("Bank", "https://bank.example.com")14        val parsed = ParsedStructure(webDomain = "shop.other.com", originDomains = listOf("other.com"))15        assertEquals(listOf("other.com"), rememberOfferDomains(bank, parsed))16    }1718    @Test fun no_offer_when_origin_domain_already_covered() {19        val bank = entry("Bank", "https://bank.example.com")20            .copy(additionalUrls = listOf("https://other.com/login"))21        val parsed = ParsedStructure(webDomain = "other.com", originDomains = listOf("other.com"))22        assertTrue(rememberOfferDomains(bank, parsed).isEmpty())23    }2425    @Test fun no_offer_for_entry_without_any_domains() {26        val note = entry("Note", null)27        val parsed = ParsedStructure(webDomain = "other.com", originDomains = listOf("other.com"))28        assertTrue(rememberOfferDomains(note, parsed).isEmpty())29    }3031    @Test fun no_offer_when_origin_has_no_domains() {32        val bank = entry("Bank", "https://bank.example.com")33        val parsed = ParsedStructure(packageName = "com.example.app")34        assertTrue(rememberOfferDomains(bank, parsed).isEmpty())35    }36}