package com.peachpasswords.qs import com.peachpasswords.vault.VaultEntry import org.junit.Assert.assertEquals import org.junit.Assert.assertNull import org.junit.Test class PeachTileServiceTest { @Test fun tile_copies_most_recent_password_entry() { val old = entry("old", password = "old-pw", modifiedAt = 10L, lastUsedAt = 20L) val newest = entry("new", password = "new-pw", modifiedAt = 100L, lastUsedAt = null) val used = entry("used", password = "used-pw", modifiedAt = 5L, lastUsedAt = 200L) val noPassword = entry("note", password = null, modifiedAt = 1_000L, lastUsedAt = 1_000L) assertEquals(used, mostRecentPasswordEntry(listOf(old, newest, used, noPassword))) } @Test fun tile_has_no_copy_target_without_password_entries() { assertNull(mostRecentPasswordEntry(listOf(entry("note", password = null, modifiedAt = 1L)))) } private fun entry( id: String, password: String?, modifiedAt: Long, lastUsedAt: Long? = null, ) = VaultEntry( id = id, title = id, password = password, createdAt = 1L, modifiedAt = modifiedAt, lastUsedAt = lastUsedAt, ) }