Export retained notification images in HTML
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package se.ajpanton.notificationlog.export
|
||||
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import se.ajpanton.notificationlog.model.NotificationAction
|
||||
import se.ajpanton.notificationlog.model.NotificationLogEntry
|
||||
import se.ajpanton.notificationlog.settings.LogViewSettings
|
||||
|
||||
class LogExporterTest {
|
||||
private val imageEntry = NotificationLogEntry(
|
||||
recordedAtEpochMillis = 0,
|
||||
packageName = "example.app",
|
||||
appName = "Example",
|
||||
action = NotificationAction.APPEARED,
|
||||
contents = "A notification [image]",
|
||||
imageId = "123e4567-e89b-12d3-a456-426614174000",
|
||||
)
|
||||
|
||||
@Test fun `text exports retain an image placeholder`() {
|
||||
assertTrue(LogExporter.csv(listOf(imageEntry), LogViewSettings()).contains("[image]"))
|
||||
assertTrue(LogExporter.formatted(listOf(imageEntry), LogViewSettings()).contains("[image]"))
|
||||
}
|
||||
|
||||
@Test fun `html replaces an image placeholder only when a support path exists`() {
|
||||
val withImage = LogExporter.html(listOf(imageEntry), LogViewSettings()) { "images/${it.imageId}.png" }
|
||||
val withoutImage = LogExporter.html(listOf(imageEntry), LogViewSettings())
|
||||
|
||||
assertTrue(withImage.contains("<img src=\"images/123e4567-e89b-12d3-a456-426614174000.png\""))
|
||||
assertFalse(withoutImage.contains("<img"))
|
||||
assertTrue(withoutImage.contains("[image]"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user