Skip to content

Commit

Permalink
Reuse asset paths mapping from sut in the test class
Browse files Browse the repository at this point in the history
  • Loading branch information
eyedol committed Jul 4, 2024
1 parent 353a9c8 commit 04b0051
Showing 1 changed file with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.takahirom.roborazzi

import junit.framework.TestCase.assertTrue
import org.junit.Before
import org.junit.Rule
import org.junit.rules.TemporaryFolder
import java.io.File
Expand All @@ -11,21 +12,22 @@ class WebAssetsTest {
@get:Rule
val tmpDir: TemporaryFolder = TemporaryFolder.builder().assureDeletion().build()

private lateinit var sut: WebAssets

@Before
fun setUp() {
sut = WebAssets.create()
}

@Test
fun testWritesWebAssetsSuccessfullyToReportsDirectory() {
val reportDir = tmpDir.newFolder("roborazzi-reports")
val cssFile = File(reportDir, "assets/report-style.css")
val materializeCssFile = File(reportDir, "assets/materialize.min.css")
val materializeJsFile = File(reportDir, "assets/materialize.min.js")
val materialIconsCssFile = File(reportDir, "assets/material-icons.css")
val materialIconsTtfFile = File(reportDir, "assets/MaterialIcons-Regular.ttf")

WebAssets.create().writeToRoborazziReportsDir(reportDir)

assertTrue(cssFile.exists())
assertTrue(materializeCssFile.exists())
assertTrue(materializeJsFile.exists())
assertTrue(materialIconsCssFile.exists())
assertTrue(materialIconsTtfFile.exists())
val assetFiles = sut.assets.map { File(reportDir, "assets/$it") }

sut.writeToRoborazziReportsDir(reportDir)

assetFiles.forEach { file->
assertTrue(file.exists())
}
}
}

0 comments on commit 04b0051

Please sign in to comment.