1package com.peachpasswords.autofill23import com.peachpasswords.autofill.AutofillResponseBuilder.FillMode4import com.peachpasswords.vault.VaultEntry5import org.junit.Assert.assertEquals6import org.junit.Assert.assertNotEquals7import org.junit.Test891011121314151617class AutofillTwoFactorChipLabelTest {1819 private fun entry(20 title: String = "GitHub",21 username: String? = "june",22 email: String? = null,23 url: String? = "https://github.com",24 totp: String? = "JBSWY3DPEHPK3PXP",25 ) = VaultEntry(26 id = title, title = title, username = username, email = email, url = url, totp = totp,27 createdAt = 0, modifiedAt = 0,28 )2930 private fun loginLabels() =31 AutofillResponseBuilder.previewLabels(32 privatePreview = false,33 entry = entry(),34 originDomain = "github.com",35 fillMode = FillMode.LOGIN,36 )3738 private fun otpLabels(code: String = "482901") =39 AutofillResponseBuilder.previewLabels(40 privatePreview = false,41 entry = entry(),42 originDomain = "github.com",43 fillMode = FillMode.OTP_FILL,44 otpCode = code,45 )4647 @Test fun login_and_2fa_chips_now_differ() {48 val login = loginLabels()49 val otp = otpLabels()50 println("--- LOGIN chip labels ---")51 println(" title=${login.title} subtitle=${login.subtitle}")52 println("--- 2FA chip labels ---")53 println(" title=${otp.title} subtitle=${otp.subtitle}")54 assertEquals("GitHub", login.title)55 assertEquals("june", login.subtitle)56 assertEquals("482 901", otp.title)57 assertEquals("2FA", otp.subtitle)58 assertNotEquals(login.title, otp.title)59 assertNotEquals(login.subtitle, otp.subtitle)60 }6162 @Test fun otp_label_tracks_the_code_passed_in() {63 64 65 66 67 val one = otpLabels("111111")68 val two = otpLabels("222222")69 assertEquals("111 111", one.title)70 assertEquals("222 222", two.title)71 }72}