|
| 1 | +package com.sysadmindoc.callshield.ui.screens.details |
| 2 | + |
| 3 | +import android.content.Context |
| 4 | +import androidx.test.core.app.ApplicationProvider |
| 5 | +import org.junit.Assert.assertFalse |
| 6 | +import org.junit.Assert.assertTrue |
| 7 | +import org.junit.Test |
| 8 | +import org.junit.runner.RunWith |
| 9 | +import org.robolectric.RobolectricTestRunner |
| 10 | +import org.robolectric.annotation.Config |
| 11 | + |
| 12 | +@RunWith(RobolectricTestRunner::class) |
| 13 | +@Config(sdk = [34]) |
| 14 | +class ReportIssueBodyTest { |
| 15 | + private val resources = ApplicationProvider.getApplicationContext<Context>().resources |
| 16 | + |
| 17 | + @Test |
| 18 | + fun `a number with nothing in the log isn't reported as seen zero times`() { |
| 19 | + // Issues #24 and #27 both arrived as "Seen 0 times": the reporter had |
| 20 | + // looked the number up by hand, so nothing from it was in the log. |
| 21 | + val body = reportIssueBody(resources, "+18056377456", 0) |
| 22 | + |
| 23 | + assertTrue(body, body.contains("+18056377456")) |
| 24 | + assertTrue(body, body.contains("No calls or texts")) |
| 25 | + assertFalse(body, body.contains("Seen 0")) |
| 26 | + } |
| 27 | + |
| 28 | + @Test |
| 29 | + fun `logged calls and texts are counted`() { |
| 30 | + assertTrue(reportIssueBody(resources, "+18056377456", 1).endsWith("Seen 1 time")) |
| 31 | + assertTrue(reportIssueBody(resources, "+18056377456", 3).endsWith("Seen 3 times")) |
| 32 | + } |
| 33 | + |
| 34 | + @Test |
| 35 | + fun `the body keeps the tracker's headings whatever the count`() { |
| 36 | + for (count in listOf(0, 2)) { |
| 37 | + val body = reportIssueBody(resources, "+18056377456", count) |
| 38 | + assertTrue(body, body.startsWith("## Phone Number\n+18056377456\n\n## Type\n")) |
| 39 | + assertTrue(body, body.contains("\n\n## Description\n")) |
| 40 | + } |
| 41 | + } |
| 42 | +} |
0 commit comments