package com.cottondb.health import com.cottondb.shell.Ground import org.json.JSONObject import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test import java.io.File /** Cotton Health on Android: its registry row, its flat ground and its own screens in place of the deck. */ class HealthFlavourTest { private val repo = generateSequence(File("").absoluteFile) { it.parentFile }.first { File(it, "apps/registry.json").isFile } private fun json(path: String) = JSONObject(File(repo, path).readText()) @Test fun health_is_built_for_android_as_cotton_health() { val apps = json("apps/registry.json").getJSONArray("apps") val row = (0 until apps.length()).map { apps.getJSONObject(it) }.single { it.getString("slug") == "health" } assertEquals("Cotton Health", row.getString("name")) assertEquals("development", row.getString("phase")) val android = row.getJSONObject("android") assertEquals("com.cottondb.health", android.getString("package")) assertEquals("com.cottondb.health.dev", android.getString("devPackage")) assertEquals("apps/android", android.getString("project")) } /** No fan, no deck, no paper: the look's flat ground, every screen Health's own, the shell's cards in its look. */ @Test fun health_draws_its_own_screens_on_its_looks_ground() { val parts = HealthParts() assertEquals(Ground.flat, parts.ground) assertFalse(parts.readsDeck) assertTrue(parts.drawsSealedKey && parts.drawsSignInAsk) val look = json("crates/cotton-core/kits/health/look.json") val window = json("apps/android/app/flavours.json").getJSONObject("health").getString("windowGround") assertEquals(look.getJSONObject("colours").getJSONObject("light").getString("background"), window) } /** Every size a chart or a state mark is drawn at is the look's (Charts.kt, Screens.kt): none written in Kotlin. */ @Test fun the_look_names_every_chart_size() { val space = json("crates/cotton-core/kits/health/look.json").getJSONObject("space") listOf("trend_width", "trend_height", "chart_height", "chart_point", "chart_line", "mark").forEach { assertTrue(it, space.has(it)) } } }