Add unit test for language manager

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/109/head
trivernis 4 years ago
parent dcfd9f11f1
commit b46b3f78cd
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -97,5 +97,7 @@ compileTestKotlin {
implementation group: 'junit', name: 'junit', version: '4.12' implementation group: 'junit', name: 'junit', version: '4.12'
implementation 'com.github.seeseemelk:MockBukkit:v1.16-SNAPSHOT' implementation 'com.github.seeseemelk:MockBukkit:v1.16-SNAPSHOT'
implementation 'io.kotest:kotest-runner-junit5:4.3.2' implementation 'io.kotest:kotest-runner-junit5:4.3.2'
implementation 'io.mockk:mockk:1.10.6'
implementation "org.dynmap:dynmap-api:2.0"
} }
} }

@ -6,12 +6,16 @@ import net.trivernis.chunkmaster.lib.LanguageManager
import net.trivernis.chunkmaster.lib.database.SqliteManager import net.trivernis.chunkmaster.lib.database.SqliteManager
import net.trivernis.chunkmaster.lib.generation.GenerationManager import net.trivernis.chunkmaster.lib.generation.GenerationManager
import org.bstats.bukkit.Metrics import org.bstats.bukkit.Metrics
import org.bukkit.plugin.PluginDescriptionFile
import org.bukkit.plugin.java.JavaPlugin import org.bukkit.plugin.java.JavaPlugin
import org.bukkit.plugin.java.JavaPluginLoader
import org.bukkit.scheduler.BukkitTask import org.bukkit.scheduler.BukkitTask
import org.dynmap.DynmapAPI import org.dynmap.DynmapAPI
import java.io.File
import java.lang.IllegalStateException import java.lang.IllegalStateException
import javax.annotation.ParametersAreNonnullByDefault
class Chunkmaster : JavaPlugin() { open class Chunkmaster : JavaPlugin() {
lateinit var sqliteManager: SqliteManager lateinit var sqliteManager: SqliteManager
lateinit var generationManager: GenerationManager lateinit var generationManager: GenerationManager
lateinit var langManager: LanguageManager lateinit var langManager: LanguageManager

@ -0,0 +1,28 @@
package net.trivernis.chunkmaster
import io.kotest.matchers.string.shouldNotBeEmpty
import io.mockk.every
import io.mockk.mockk
import net.trivernis.chunkmaster.lib.LanguageManager
import org.bukkit.configuration.file.FileConfiguration
import org.junit.Test
class LanguageManagerTest {
private var langManager: LanguageManager
init {
val plugin = mockk<Chunkmaster>()
val config = mockk<FileConfiguration>()
every {plugin.dataFolder} returns createTempDir()
every {plugin.config} returns config
every {config.getString("language")} returns "en"
langManager = LanguageManager(plugin)
langManager.loadProperties()
}
@Test
fun `it returns localized for a key`() {
langManager.getLocalized("NOT_PAUSED").shouldNotBeEmpty()
}
}
Loading…
Cancel
Save