feat: card repository and home three-column layout
This commit is contained in:
@@ -2,6 +2,10 @@ package top.yeij.hearth.webview
|
||||
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import top.yeij.hearth.card.CardRepository
|
||||
import top.yeij.hearth.cache.CacheManager
|
||||
import top.yeij.hearth.webapp.HttpClient
|
||||
import java.io.File
|
||||
|
||||
class JsBridgeTest {
|
||||
@Test
|
||||
@@ -11,4 +15,27 @@ class JsBridgeTest {
|
||||
assertTrue(json.contains("\"widthPx\":800"))
|
||||
assertTrue(json.contains("\"darkMode\":true"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun fetchCards_withoutRepository_returnsEmptyArray() {
|
||||
val bridge = JsBridge(deviceWidthPx = 800, deviceHeightPx = 480, density = 2.0f, darkMode = true)
|
||||
assertTrue(bridge.fetchCards() == "[]")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun fetchCards_withRepository_returnsBuiltinTimeCard() {
|
||||
val dir = File(System.getProperty("java.io.tmpdir"), "jb-cards")
|
||||
val repo = CardRepository(
|
||||
object : HttpClient { override fun get(url: String): String? = null },
|
||||
CacheManager(dir),
|
||||
"http://fake",
|
||||
)
|
||||
val bridge = JsBridge(
|
||||
deviceWidthPx = 800, deviceHeightPx = 480, density = 2.0f, darkMode = true,
|
||||
cardRepository = repo,
|
||||
)
|
||||
val json = bridge.fetchCards()
|
||||
assertTrue(json.contains("\"id\":\"time\""))
|
||||
dir.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user