diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-03-23 18:04:47 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-03-23 18:04:47 +0100 |
commit | 45bbfe53a19a16127adf68f23325dd139fec89ca (patch) | |
tree | 100729d2149e35ad03858a8aef10165f6c916917 | |
parent | 450728a1f6efa6070b537734a4ed6bfa9022ec94 (diff) | |
download | kvision-45bbfe53a19a16127adf68f23325dd139fec89ca.tar.gz kvision-45bbfe53a19a16127adf68f23325dd139fec89ca.tar.bz2 kvision-45bbfe53a19a16127adf68f23325dd139fec89ca.zip |
Unit tests for progress bar components.
-rw-r--r-- | src/test/kotlin/test/pl/treksoft/kvision/progress/ProgressBarSpec.kt | 38 | ||||
-rw-r--r-- | src/test/kotlin/test/pl/treksoft/kvision/progress/ProgressIndicatorSpec.kt | 37 |
2 files changed, 75 insertions, 0 deletions
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/progress/ProgressBarSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/progress/ProgressBarSpec.kt new file mode 100644 index 00000000..0ca5c7de --- /dev/null +++ b/src/test/kotlin/test/pl/treksoft/kvision/progress/ProgressBarSpec.kt @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018. Robert Jaros + */ +package test.pl.treksoft.kvision.progress + +import pl.treksoft.kvision.panel.Root +import pl.treksoft.kvision.progress.ProgressBar +import pl.treksoft.kvision.progress.ProgressBarStyle +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test + +class ProgressBarSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test", true) + val progressBar = + ProgressBar(50, style = ProgressBarStyle.SUCCESS, striped = true, content = "Processing ...") + root.add(progressBar) + val element = document.getElementById("test") + assertEqualsHtml( + "<div class=\"progress\"><div class=\"progress-bar progress-bar-success progress-bar-striped\" role=\"progressbar\" aria-valuenow=\"50\" aria-valuemin=\"0\" aria-valuemax=\"100\" style=\"width: 50%;\">Processing ...</div></div>", + element?.innerHTML, + "Should render correct progress bar" + ) + progressBar.max = 200 + assertEqualsHtml( + "<div class=\"progress\"><div class=\"progress-bar progress-bar-success progress-bar-striped\" role=\"progressbar\" aria-valuenow=\"50\" aria-valuemin=\"0\" aria-valuemax=\"200\" style=\"width: 25%;\">Processing ...</div></div>", + element?.innerHTML, + "Should render correct progress bar after max value change" + ) + + } + } + +} diff --git a/src/test/kotlin/test/pl/treksoft/kvision/progress/ProgressIndicatorSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/progress/ProgressIndicatorSpec.kt new file mode 100644 index 00000000..21247ba4 --- /dev/null +++ b/src/test/kotlin/test/pl/treksoft/kvision/progress/ProgressIndicatorSpec.kt @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018. Robert Jaros + */ +package test.pl.treksoft.kvision.progress + +import pl.treksoft.kvision.panel.Root +import pl.treksoft.kvision.progress.ProgressBarStyle +import pl.treksoft.kvision.progress.ProgressIndicator +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test + +class ProgressIndicatorSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test", true) + val ind = ProgressIndicator(50, style = ProgressBarStyle.SUCCESS, striped = true) + root.add(ind) + val element = document.getElementById("test") + assertEqualsHtml( + "<div class=\"progress-bar progress-bar-success progress-bar-striped\" role=\"progressbar\" aria-valuenow=\"50\" aria-valuemin=\"0\" aria-valuemax=\"100\" style=\"width: 50%;\"></div>", + element?.innerHTML, + "Should render correct progress bar indicator" + ) + ind.max = 200 + assertEqualsHtml( + "<div class=\"progress-bar progress-bar-success progress-bar-striped\" role=\"progressbar\" aria-valuenow=\"50\" aria-valuemin=\"0\" aria-valuemax=\"200\" style=\"width: 25%;\"></div>", + element?.innerHTML, + "Should render correct progress bar indicator after max value change" + ) + + } + } + +} |