4
0
Fork 0
mirror of https://github.com/Anvilcraft/modpacktools synced 2024-06-02 18:49:31 +02:00
modpacktools/src/test/kotlin/ley/anvil/modpacktools/util/UtilTest.kt
2020-08-14 11:20:36 +02:00

32 lines
795 B
Kotlin

package ley.anvil.modpacktools.util
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.rules.TemporaryFolder
import java.io.File
import java.net.URL
class UtilTest {
@Test
fun sanitize() = assertEquals(URL("https://example.com/test%20test"), URL("https://example.com/test test").sanitize())
@Test
fun mergeTo() = assertEquals(File("testing/dir"), File("testing") mergeTo File("dir"))
@Test
fun readAsJson() {
val tmpDir = TemporaryFolder().apply {create()}
val testFile = tmpDir.newFile()
testFile.writeText(
"""
{
"someKey": "someValue"
}
""".trimIndent()
)
assertEquals("someValue", testFile.readAsJson()["someKey"].asString)
}
}