PeachTileServiceTest.kt

1.2 KB · raw

1package com.peachpasswords.qs23import com.peachpasswords.vault.VaultEntry4import org.junit.Assert.assertEquals5import org.junit.Assert.assertNull6import org.junit.Test78class PeachTileServiceTest {9    @Test fun tile_copies_most_recent_password_entry() {10        val old = entry("old", password = "old-pw", modifiedAt = 10L, lastUsedAt = 20L)11        val newest = entry("new", password = "new-pw", modifiedAt = 100L, lastUsedAt = null)12        val used = entry("used", password = "used-pw", modifiedAt = 5L, lastUsedAt = 200L)13        val noPassword = entry("note", password = null, modifiedAt = 1_000L, lastUsedAt = 1_000L)1415        assertEquals(used, mostRecentPasswordEntry(listOf(old, newest, used, noPassword)))16    }1718    @Test fun tile_has_no_copy_target_without_password_entries() {19        assertNull(mostRecentPasswordEntry(listOf(entry("note", password = null, modifiedAt = 1L))))20    }2122    private fun entry(23        id: String,24        password: String?,25        modifiedAt: Long,26        lastUsedAt: Long? = null,27    ) = VaultEntry(28        id = id,29        title = id,30        password = password,31        createdAt = 1L,32        modifiedAt = modifiedAt,33        lastUsedAt = lastUsedAt,34    )35}