1package com.peachpasswords.autofill23import com.peachpasswords.vault.VaultEntry4import org.junit.Assert.assertEquals5import org.junit.Test67class AutofillPreviewLabelsTest {8 private fun entry(9 title: String = "GitHub",10 username: String? = "june",11 email: String? = null,12 url: String? = "https://github.com",13 ) = VaultEntry(14 id = title, title = title, username = username, email = email, url = url,15 createdAt = 0, modifiedAt = 0,16 )1718 @Test fun normal_mode_shows_entry_title_and_identity() {19 val labels = AutofillResponseBuilder.previewLabels(false, entry(), "github.com")20 assertEquals("GitHub", labels.title)21 assertEquals("june", labels.subtitle)22 }2324 @Test fun normal_mode_falls_back_email_then_domain() {25 val emailOnly = entry(username = null, email = "[email protected]")26 assertEquals("[email protected]", AutofillResponseBuilder.previewLabels(false, emailOnly, null).subtitle)27 val bare = entry(username = null, email = null)28 assertEquals("github.com", AutofillResponseBuilder.previewLabels(false, bare, null).subtitle)29 }3031 @Test fun private_mode_hides_title_and_identity() {32 val labels = AutofillResponseBuilder.previewLabels(true, entry(), "github.com")33 assertEquals("Peach", labels.title)34 assertEquals("github.com", labels.subtitle)35 }3637 @Test fun private_mode_without_origin_has_blank_subtitle() {38 val labels = AutofillResponseBuilder.previewLabels(true, entry(), null)39 assertEquals("Peach", labels.title)40 assertEquals("", labels.subtitle)41 }42}