package com.peachpasswords.autofill import com.peachpasswords.vault.VaultEntry import org.junit.Assert.assertEquals import org.junit.Test class AutofillPreviewLabelsTest { private fun entry( title: String = "GitHub", username: String? = "june", email: String? = null, url: String? = "https://github.com", ) = VaultEntry( id = title, title = title, username = username, email = email, url = url, createdAt = 0, modifiedAt = 0, ) @Test fun normal_mode_shows_entry_title_and_identity() { val labels = AutofillResponseBuilder.previewLabels(false, entry(), "github.com") assertEquals("GitHub", labels.title) assertEquals("june", labels.subtitle) } @Test fun normal_mode_falls_back_email_then_domain() { val emailOnly = entry(username = null, email = "june@example.com") assertEquals("june@example.com", AutofillResponseBuilder.previewLabels(false, emailOnly, null).subtitle) val bare = entry(username = null, email = null) assertEquals("github.com", AutofillResponseBuilder.previewLabels(false, bare, null).subtitle) } @Test fun private_mode_hides_title_and_identity() { val labels = AutofillResponseBuilder.previewLabels(true, entry(), "github.com") assertEquals("Peach", labels.title) assertEquals("github.com", labels.subtitle) } @Test fun private_mode_without_origin_has_blank_subtitle() { val labels = AutofillResponseBuilder.previewLabels(true, entry(), null) assertEquals("Peach", labels.title) assertEquals("", labels.subtitle) } }