package com.cottondb.healthimport com.cottondb.shell.Groundimport org.json.JSONObjectimport org.junit.Assert.assertEqualsimport org.junit.Assert.assertFalseimport org.junit.Assert.assertTrueimport org.junit.Testimport java.io.File/** Cotton Health on Android: its registry row, its flat ground and its own screens in place of the deck. */classHealthFlavourTest {privateval repo = generateSequence(File("").absoluteFile) { it.parentFile }.first { File(it, "apps/registry.json").isFile }privatefun json(path: String) = JSONObject(File(repo, path).readText()) @Testfun 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. */ @Testfun 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. */ @Testfun 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)) } }}