diff --git a/README.md b/README.md index 3020fd88e..f042b1945 100644 --- a/README.md +++ b/README.md @@ -100,14 +100,17 @@ See [Plugin Signing](https://plugins.jetbrains.com/docs/intellij/plugin-signing. ```bash $ gradlew test # Run tests (and collect coverage) $ gradlew test --tests X # Run tests in class X (package name optional) -$ gradlew test -Pkotest.tags="X" # Run tests with `NamedTag` X (also supports not (!), and (&), or (|)) +$ gradlew test -Pkotest.tags="X" # Run tests matching tag(s) X (also supports not (!), and (&), or (|)) $ gradlew koverHtmlReport # Create HTML coverage report for previous test run $ gradlew check # Run tests and static analysis $ gradlew runPluginVerifier # Check for compatibility issues ``` -#### 🏷️ Filtering tests +#### 🏷️ Tagging and filtering tests [Kotest tests can be tagged](https://kotest.io/docs/framework/tags.html) to allow selectively running tests. +The tags for Randomness are statically defined in +[`Tags`](https://github.com/FWDekker/intellij-randomness/blob/main/src/test/kotlin/com/fwdekker/randomness/testhelpers/Tags.kt). + Tag an entire test class by adding `tags(...)` to the class definition, or tag an individual test `context` by writing `context("foo").config(tags = setOf(...)) {`. It is not possible to tag an individual `test` due to limitations in Kotest. diff --git a/src/main/kotlin/com/fwdekker/randomness/Icons.kt b/src/main/kotlin/com/fwdekker/randomness/Icons.kt index e654ce99a..afddb9ef0 100644 --- a/src/main/kotlin/com/fwdekker/randomness/Icons.kt +++ b/src/main/kotlin/com/fwdekker/randomness/Icons.kt @@ -85,17 +85,6 @@ data class TypeIcon(val base: Icon, val text: String, val colors: List) : } - /** - * Returns an icon that describes both this icon's type and [other]'s type. - */ - fun combineWith(other: TypeIcon) = - TypeIcon( - Icons.TEMPLATE, - if (this.text == other.text) this.text else "", - this.colors + other.colors - ) - - /** * Paints the colored text icon. * @@ -133,6 +122,18 @@ data class TypeIcon(val base: Icon, val text: String, val colors: List) : * The scale of the text inside the icon relative to the icon's size. */ const val FONT_SIZE = 12f / 32f + + + /** + * Returns a single icon that describes all [icons], or `null` if [icons] is empty. + */ + fun combine(icons: Collection): TypeIcon? = + if (icons.isEmpty()) null + else TypeIcon( + Icons.TEMPLATE, + if (icons.map { it.text }.toSet().size == 1) icons.first().text else "", + icons.flatMap { it.colors } + ) } } diff --git a/src/main/kotlin/com/fwdekker/randomness/PopupAction.kt b/src/main/kotlin/com/fwdekker/randomness/PopupAction.kt index 37663ff6e..2938349f8 100644 --- a/src/main/kotlin/com/fwdekker/randomness/PopupAction.kt +++ b/src/main/kotlin/com/fwdekker/randomness/PopupAction.kt @@ -40,7 +40,7 @@ class PopupAction : AnAction(Icons.RANDOMNESS) { override fun update(event: AnActionEvent) { event.presentation.icon = Icons.RANDOMNESS - // Running this in `actionPerformed` always sets it to `true` + // Running this in [actionPerformed] always sets it to `true` isEditable = event.getData(CommonDataKeys.EDITOR)?.isViewer == false } @@ -54,7 +54,7 @@ class PopupAction : AnAction(Icons.RANDOMNESS) { val popup = JBPopupFactory.getInstance() .createActionGroupPopup( Bundle("popup.title"), popupGroup, event.dataContext, - JBPopupFactory.ActionSelectionAid.NUMBERING, + JBPopupFactory.ActionSelectionAid.ALPHA_NUMBERING, true ) as ListPopupImpl @@ -125,11 +125,25 @@ class PopupAction : AnAction(Icons.RANDOMNESS) { Separator() + TemplateSettingsAction() } + + + /** + * Holds constants. + */ + companion object { + /** + * Returns the mnemonic for the entry at the [index]th row. + * + * @see JBPopupFactory.ActionSelectionAid.ALPHA_NUMBERING + */ + fun indexToMnemonic(index: Int) = + (('1'..'9') + '0' + ('A'..'Z')).getOrNull(index) + } } /** - * An `AbstractAction` that uses [myActionPerformed] as the implementation of its [actionPerformed] method. + * An [AbstractAction] that uses [myActionPerformed] as the implementation of its [actionPerformed] method. * * @property myActionPerformed The code to execute in [actionPerformed]. */ @@ -201,26 +215,28 @@ fun ListPopupImpl.registerModifierActions(captionModifier: (ActionEvent?) -> Str } ) - @Suppress("detekt:MagicNumber") // Not worth a constant - for (key in 0..9) { - registerAction( - "${a}${b}${c}invokeAction$key", - KeyStroke.getKeyStroke("$a $b $c pressed $key"), - SimpleAbstractAction { event -> - event ?: return@SimpleAbstractAction - - val targetRow = if (key == 0) 9 else key - 1 - list.addSelectionInterval(targetRow, targetRow) - handleSelect( - true, - KeyEvent( - component, - event.id, event.getWhen(), event.modifiers, - KeyEvent.VK_ENTER, KeyEvent.CHAR_UNDEFINED, KeyEvent.KEY_LOCATION_UNKNOWN + @Suppress("detekt:ForEachOnRange") // Not relevant for such small numbers + (0 until list.model.size) + .associateWith { PopupAction.indexToMnemonic(it) } + .filterValues { it != null } + .forEach { (index, mnemonic) -> + registerAction( + "${a}${b}${c}invokeAction$mnemonic", + KeyStroke.getKeyStroke("$a $b $c pressed $mnemonic"), + SimpleAbstractAction { event -> + event ?: return@SimpleAbstractAction + + list.addSelectionInterval(index, index) + handleSelect( + true, + KeyEvent( + component, + event.id, event.getWhen(), event.modifiers, + KeyEvent.VK_ENTER, KeyEvent.CHAR_UNDEFINED, KeyEvent.KEY_LOCATION_UNKNOWN + ) ) - ) - } - ) - } + } + ) + } } } diff --git a/src/main/kotlin/com/fwdekker/randomness/XmlHelpers.kt b/src/main/kotlin/com/fwdekker/randomness/XmlHelpers.kt index fe9082f42..9457d846a 100644 --- a/src/main/kotlin/com/fwdekker/randomness/XmlHelpers.kt +++ b/src/main/kotlin/com/fwdekker/randomness/XmlHelpers.kt @@ -4,36 +4,36 @@ import org.jdom.Element /** - * Returns a list of all [Element]s contained in this `Element`. + * Returns a list of all [Element]s contained in this [Element]. */ fun Element.getElements(): List = content().toList().filterIsInstance() /** - * Returns the [Element] contained in this `Element` that has attribute `name="[name]"`, or `null` if no single such - * `Element` exists. + * Returns the [Element] contained in this [Element] that has attribute `name="[name]"`, or `null` if no single such + * [Element] exists. */ fun Element.getContentByName(name: String): Element? = getContent { (it as Element).getAttribute("name")?.value == name }.singleOrNull() /** - * Returns the value of the `value` attribute of the single [Element] contained in this `Element` that has attribute - * `name="[name]"`, or `null` if no single such `Element` exists. + * Returns the value of the `value` attribute of the single [Element] contained in this [Element] that has attribute + * `name="[name]"`, or `null` if no single such [Element] exists. */ fun Element.getAttributeValueByName(name: String): String? = getContentByName(name)?.getAttribute("value")?.value /** - * Sets the value of the `value` attribute of the single [Element] contained in this `Element` that has attribute - * `name="[name]"` to [value], or does nothing if no single such `Element` exists. + * Sets the value of the `value` attribute of the single [Element] contained in this [Element] that has attribute + * `name="[name]"` to [value], or does nothing if no single such [Element] exists. */ fun Element.setAttributeValueByName(name: String, value: String) { getContentByName(name)?.setAttribute("value", value) } /** - * Returns the single [Element] that is contained in this `Element`, or `null` if this `Element` does not contain - * exactly one `Element`. + * Returns the single [Element] that is contained in this [Element], or `null` if this [Element] does not contain + * exactly one [Element]. */ fun Element.getSingleContent(): Element? = content.singleOrNull() as? Element diff --git a/src/main/kotlin/com/fwdekker/randomness/datetime/DateTimeSchemeEditor.kt b/src/main/kotlin/com/fwdekker/randomness/datetime/DateTimeSchemeEditor.kt index ea05037df..a14fb6e3d 100644 --- a/src/main/kotlin/com/fwdekker/randomness/datetime/DateTimeSchemeEditor.kt +++ b/src/main/kotlin/com/fwdekker/randomness/datetime/DateTimeSchemeEditor.kt @@ -73,7 +73,7 @@ class DateTimeSchemeEditor(scheme: DateTimeScheme = DateTimeScheme()) : SchemeEd /** - * Binds two `DateTimePicker`s together, analogous to how [com.fwdekker.randomness.ui.bindSpinners] works. + * Binds two [JDateTimeField]s together, analogous to how [com.fwdekker.randomness.ui.bindSpinners] works. */ private fun bindDateTimes(minField: JDateTimeField, maxField: JDateTimeField) { addChangeListenerTo(minField) { diff --git a/src/main/kotlin/com/fwdekker/randomness/template/Template.kt b/src/main/kotlin/com/fwdekker/randomness/template/Template.kt index 4bf926f5a..414f7b898 100644 --- a/src/main/kotlin/com/fwdekker/randomness/template/Template.kt +++ b/src/main/kotlin/com/fwdekker/randomness/template/Template.kt @@ -42,7 +42,7 @@ data class Template( val arrayDecorator: ArrayDecorator = DEFAULT_ARRAY_DECORATOR, ) : Scheme() { override val typeIcon - get() = schemes.mapNotNull { it.typeIcon }.reduceOrNull { acc, icon -> acc.combineWith(icon) } ?: DEFAULT_ICON + get() = TypeIcon.combine(schemes.mapNotNull { it.typeIcon }) ?: DEFAULT_ICON override val decorators get() = listOf(arrayDecorator) /** diff --git a/src/main/kotlin/com/fwdekker/randomness/template/TemplateJTree.kt b/src/main/kotlin/com/fwdekker/randomness/template/TemplateJTree.kt index a3dd9f036..f656c99ab 100644 --- a/src/main/kotlin/com/fwdekker/randomness/template/TemplateJTree.kt +++ b/src/main/kotlin/com/fwdekker/randomness/template/TemplateJTree.kt @@ -1,6 +1,7 @@ package com.fwdekker.randomness.template import com.fwdekker.randomness.Bundle +import com.fwdekker.randomness.PopupAction import com.fwdekker.randomness.Scheme import com.fwdekker.randomness.datetime.DateTimeScheme import com.fwdekker.randomness.decimal.DecimalScheme @@ -28,8 +29,6 @@ import com.intellij.ui.treeStructure.Tree import com.intellij.util.ui.JBUI import javax.swing.JPanel import javax.swing.JTree -import javax.swing.event.TreeExpansionEvent -import javax.swing.event.TreeWillExpandListener import javax.swing.tree.TreeSelectionModel import kotlin.math.min @@ -80,7 +79,8 @@ class TemplateJTree( /** * The currently selected scheme (or template), or `null` if no scheme is currently selected. * - * Setting a scheme that is either `null` or not in the tree will clear the current selection. + * Setting `null` or setting a [Scheme] with a UUID that does not occur in this tree will clear the current + * selection. */ var selectedScheme: Scheme? get() = selectedNodeNotRoot?.state as? Scheme @@ -114,15 +114,27 @@ class TemplateJTree( } /** - * UUIDs of templates that have explicitly been collapsed. + * The list of currently-collapsed [Template]s by UUID. * - * Though a [TemplateJTree] knows which rows in the tree have been expanded and collapsed, it does not know by - * itself which templates these rows belong to. The tree would normally use the [myModel] to find this out, but that - * does not work if the UI and the model have become desynchronized, as is the case during [reload]. Therefore, the - * [collapsedNodes] field can be used even while desynchronized to determine which templates are collapsed, and, - * in particular, which templates should (not) be expanded after resynchronization. + * This field is rather finicky. It is used in [runPreservingState], which is used in [reload], which may be invoked + * while the UI and the [myModel] are desynchronized. Therefore, in the getter, this field uses [getUI] to access + * the (possibly outdated) UI to determine which [Template]s have currently been collapsed. In the setter, + * meanwhile, all [Template]s are expanded except the given [Template]s, to ensure that new [Template]s (which were + * added in such a way as to cause desynchronization) are expanded by default. */ - private val collapsedNodes = currentTemplateList.templates.map { it.uuid }.toMutableSet() + private var collapsedTemplates: Collection + get() { + val ui = getUI() ?: return emptyList() + + return (0 until ui.getRowCount(this)) + .mapNotNull { ui.getPathForRow(this, it) } + .filter { isCollapsed(it) } + .map { (it.lastPathComponent as StateNode).state.uuid } + } + set(value) = + myModel.root.children + .filter { it.state.uuid !in value } + .forEach { expandPath(myModel.getPathToRoot(it)) } init { @@ -133,15 +145,6 @@ class TemplateJTree( showsRootHandles = true selectionModel.selectionMode = TreeSelectionModel.SINGLE_TREE_SELECTION setCellRenderer(CellRenderer()) - addTreeWillExpandListener(object : TreeWillExpandListener { - override fun treeWillExpand(event: TreeExpansionEvent) { - collapsedNodes -= (event.path.lastPathComponent as StateNode).state.uuid - } - - override fun treeWillCollapse(event: TreeExpansionEvent) { - collapsedNodes += (event.path.lastPathComponent as StateNode).state.uuid - } - }) setSelectionRow(0) } @@ -183,24 +186,21 @@ class TemplateJTree( * resynchronized. Otherwise, if [changedScheme] is `null`, the entire model is resynchronized. * * This is a wrapper around [TemplateJTreeModel.fireNodeStructureChanged] that additionally tries to retain the - * current selection and expansion state. Any new templates that have been added will initially be collapsed. + * current selection and expansion state. Any new templates that have been added will initially be expanded. * * @see runPreservingState */ fun reload(changedScheme: Scheme? = null) { runPreservingState { myModel.fireNodeStructureChanged(changedScheme?.let { StateNode(it) } ?: myModel.root) } - selectedScheme = selectedScheme ?: currentTemplateList.templates.firstOrNull() + if (selectedScheme == null) + selectedScheme = currentTemplateList.templates.firstOrNull() } /** - * Expands the [Template]s identified by [uuids], and collapses all other [Template]s. + * Expands all [Template]s. */ - fun expandNodes(uuids: Collection = currentTemplateList.templates.map { it.uuid }) = - myModel.root.children - .associateWith { it.state.uuid in uuids } - .mapKeys { myModel.getPathToRoot(it.key) } - .forEach { (path, shouldExpand) -> setExpandedState(path, shouldExpand) } + fun expandAll() = myModel.root.children.forEach { expandPath(myModel.getPathToRoot(it)) } /** @@ -257,7 +257,7 @@ class TemplateJTree( /** * Replaces [oldScheme] with [newScheme] in-place. * - * If `newScheme` is `null`, then `oldScheme` is removed without being replaced. + * If [newScheme] is `null`, then [oldScheme] is removed without being replaced. */ fun replaceScheme(oldScheme: Scheme, newScheme: Scheme?) { if (newScheme == null) { @@ -320,15 +320,15 @@ class TemplateJTree( /** - * Runs [lambda] while ensuring that the [selectedScheme] and [collapsedNodes] remain unchanged. + * Runs [lambda] while ensuring that the [selectedScheme] and collapsed templates remain unchanged. */ private fun runPreservingState(lambda: () -> Unit) { val oldSelected = selectedScheme - val oldCollapsed = collapsedNodes + val oldCollapsed = collapsedTemplates lambda() - expandNodes(currentTemplateList.templates.map { it.uuid }.toSet() - oldCollapsed) + collapsedTemplates = oldCollapsed selectedScheme = oldSelected } @@ -386,9 +386,8 @@ class TemplateJTree( icon = scheme.icon if (scheme is Template) { - val index = currentTemplateList.templates.indexOf(scheme) + 1 - if (index <= INDEXED_TEMPLATE_COUNT) - append("${index % INDEXED_TEMPLATE_COUNT} ", SimpleTextAttributes.GRAYED_SMALL_ATTRIBUTES, false) + PopupAction.indexToMnemonic(currentTemplateList.templates.indexOf(scheme)) + ?.run { append("$this ", SimpleTextAttributes.GRAYED_SMALL_ATTRIBUTES, false) } } append( @@ -467,12 +466,12 @@ class TemplateJTree( /** * Inserts [value] into the tree. * - * Subclasses may modify the behavior of this method to instead return the `PopupStep` nested under this + * Subclasses may modify the behavior of this method to instead return the [PopupStep] nested under this * entry. * * @param value the value to insert * @param finalChoice ignored - * @return `null`, or the `PopupStep` that is nested under this entry + * @return `null`, or the [PopupStep] that is nested under this entry */ override fun onChosen(value: Scheme?, finalChoice: Boolean): PopupStep<*>? { if (value != null) @@ -691,10 +690,5 @@ class TemplateJTree( DateTimeScheme(), TemplateReference(), ) - - /** - * Number of [Template]s that should be rendered with the index in front. - */ - const val INDEXED_TEMPLATE_COUNT = 10 } } diff --git a/src/main/kotlin/com/fwdekker/randomness/template/TemplateList.kt b/src/main/kotlin/com/fwdekker/randomness/template/TemplateList.kt index 70bafb533..f3ba61622 100644 --- a/src/main/kotlin/com/fwdekker/randomness/template/TemplateList.kt +++ b/src/main/kotlin/com/fwdekker/randomness/template/TemplateList.kt @@ -33,12 +33,13 @@ data class TemplateList( /** - * Returns the template in this list with [uuid] as its UUID. + * Returns the template in this list that has [uuid] as its UUID, or `null` if there is no such template. */ fun getTemplateByUuid(uuid: String) = templates.singleOrNull { it.uuid == uuid } /** - * Returns the template or scheme in this list with [uuid] as its UUID. + * Returns the template or scheme in this list that has [uuid] as its UUID, or `null` if there is no such template + * or scheme. */ fun getSchemeByUuid(uuid: String) = templates.flatMap { listOf(it) + it.schemes }.singleOrNull { it.uuid == uuid } diff --git a/src/main/kotlin/com/fwdekker/randomness/template/TemplateListConfigurable.kt b/src/main/kotlin/com/fwdekker/randomness/template/TemplateListConfigurable.kt index 6ce97fde1..422aeed20 100644 --- a/src/main/kotlin/com/fwdekker/randomness/template/TemplateListConfigurable.kt +++ b/src/main/kotlin/com/fwdekker/randomness/template/TemplateListConfigurable.kt @@ -24,7 +24,7 @@ class TemplateListConfigurable : Configurable, Disposable { /** * The user interface for changing the settings, displayed in IntelliJ's settings window. */ - @Suppress("detekt:LateinitUsage") // Initialized in `createComponent` + @Suppress("detekt:LateinitUsage") // Initialized in [createComponent] lateinit var editor: TemplateListEditor private set /** diff --git a/src/main/kotlin/com/fwdekker/randomness/template/TemplateListEditor.kt b/src/main/kotlin/com/fwdekker/randomness/template/TemplateListEditor.kt index 68fff6241..4375ce3fd 100644 --- a/src/main/kotlin/com/fwdekker/randomness/template/TemplateListEditor.kt +++ b/src/main/kotlin/com/fwdekker/randomness/template/TemplateListEditor.kt @@ -81,7 +81,7 @@ class TemplateListEditor( // Load current state reset() - templateTree.expandNodes() + templateTree.expandAll() // Select a scheme initialSelection diff --git a/src/main/kotlin/com/fwdekker/randomness/ui/InterfaceBuilderHelpers.kt b/src/main/kotlin/com/fwdekker/randomness/ui/InterfaceBuilderHelpers.kt index d73b3fe97..bbdef7743 100644 --- a/src/main/kotlin/com/fwdekker/randomness/ui/InterfaceBuilderHelpers.kt +++ b/src/main/kotlin/com/fwdekker/randomness/ui/InterfaceBuilderHelpers.kt @@ -128,8 +128,14 @@ fun Cell>.withSimpleRenderer(toString: (E) -> String = { it.toSt * A predicate that always returns [output]. */ class LiteralPredicate(private val output: Boolean) : ComponentPredicate() { + /** + * Does nothing, because there's no need to respond to any events to determine the output of [invoke]. + */ override fun addListener(listener: (Boolean) -> Unit) = Unit + /** + * Returns [output]. + */ override fun invoke() = output } diff --git a/src/main/kotlin/com/fwdekker/randomness/ui/JNumberSpinners.kt b/src/main/kotlin/com/fwdekker/randomness/ui/JNumberSpinners.kt index 2dee8ccf6..97bc802c3 100644 --- a/src/main/kotlin/com/fwdekker/randomness/ui/JNumberSpinners.kt +++ b/src/main/kotlin/com/fwdekker/randomness/ui/JNumberSpinners.kt @@ -57,8 +57,8 @@ abstract class JNumberSpinner(value: T, minValue: T?, maxValue: T?, stepSize: /** * A [JNumberSpinner] for doubles. * - * Note that setting `minValue` or `maxValue` to a very large number may cause the parent component's width to be overly - * large. + * Note that setting the minimum or maximum value to a very large number may cause the parent component's width to be + * overly large. * * @param value the default value * @param minValue the smallest number that may be represented diff --git a/src/main/kotlin/com/fwdekker/randomness/ui/PreviewPanel.kt b/src/main/kotlin/com/fwdekker/randomness/ui/PreviewPanel.kt index b46d3ea8d..0a913e3c7 100644 --- a/src/main/kotlin/com/fwdekker/randomness/ui/PreviewPanel.kt +++ b/src/main/kotlin/com/fwdekker/randomness/ui/PreviewPanel.kt @@ -84,7 +84,7 @@ class PreviewPanel(private val getScheme: () -> Scheme) : Disposable { /** * Updates the preview with the current settings. */ - @Suppress("SwallowedException") // Alternative is to add coupling to `SettingsComponent` + @Suppress("SwallowedException") // Alternative is to add coupling to [SettingsComponent] fun updatePreview() { try { previewText = generateTimely { getScheme().also { it.random = Random(seed) }.generateStrings() }.first() diff --git a/src/main/kotlin/com/fwdekker/randomness/word/WordSchemeEditor.kt b/src/main/kotlin/com/fwdekker/randomness/word/WordSchemeEditor.kt index 5f4d6aa35..19d32e0ba 100644 --- a/src/main/kotlin/com/fwdekker/randomness/word/WordSchemeEditor.kt +++ b/src/main/kotlin/com/fwdekker/randomness/word/WordSchemeEditor.kt @@ -147,7 +147,7 @@ fun Document.setWordList(wordList: List) = /** * Returns a [Disposable] that can dispose the [editor] through the [EditorFactory] that created it. */ -@Suppress("ObjectLiteralToLambda") // `Disposable` docs state that lambdas should be avoided +@Suppress("ObjectLiteralToLambda") // [Disposable] docs state that lambdas should be avoided private fun EditorFactory.wrapDisposable(editor: Editor) = object : Disposable { override fun dispose() = this@wrapDisposable.releaseEditor(editor) diff --git a/src/test/kotlin/com/fwdekker/randomness/CapitalizationModeTest.kt b/src/test/kotlin/com/fwdekker/randomness/CapitalizationModeTest.kt index d3a31dc73..e283318e7 100644 --- a/src/test/kotlin/com/fwdekker/randomness/CapitalizationModeTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/CapitalizationModeTest.kt @@ -1,7 +1,9 @@ package com.fwdekker.randomness +import com.fwdekker.randomness.testhelpers.matchBundle import io.kotest.assertions.retry import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.should import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldNotBe import io.kotest.matchers.string.shouldBeEqualIgnoringCase @@ -72,7 +74,7 @@ object CapitalizationModeTest : FunSpec({ context("toLocalizedString") { test("returns the associated localized string") { - CapitalizationMode.FIRST_LETTER.toLocalizedString() shouldBe Bundle("shared.capitalization.first_letter") + CapitalizationMode.FIRST_LETTER.toLocalizedString() should matchBundle("shared.capitalization.first_letter") } } }) diff --git a/src/test/kotlin/com/fwdekker/randomness/ErrorReporterTest.kt b/src/test/kotlin/com/fwdekker/randomness/ErrorReporterTest.kt index 515d625a7..2c1709846 100644 --- a/src/test/kotlin/com/fwdekker/randomness/ErrorReporterTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/ErrorReporterTest.kt @@ -1,10 +1,10 @@ package com.fwdekker.randomness +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.afterNonContainer import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.intellij.testFramework.fixtures.IdeaTestFixture import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.string.shouldContain import io.kotest.matchers.string.shouldNotContain @@ -14,7 +14,7 @@ import io.kotest.matchers.string.shouldNotContain * Unit tests for [ErrorReporter]. */ object ErrorReporterTest : FunSpec({ - tags(NamedTag("IdeaFixture")) + tags(Tags.IDEA_FIXTURE) lateinit var ideaFixture: IdeaTestFixture diff --git a/src/test/kotlin/com/fwdekker/randomness/IconsTest.kt b/src/test/kotlin/com/fwdekker/randomness/IconsTest.kt index efd1fa4b0..f6ab4ea81 100644 --- a/src/test/kotlin/com/fwdekker/randomness/IconsTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/IconsTest.kt @@ -1,12 +1,13 @@ package com.fwdekker.randomness +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.fwdekker.randomness.testhelpers.guiGet import io.kotest.assertions.throwables.shouldThrow -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.collections.beEmpty import io.kotest.matchers.collections.shouldContainExactly +import io.kotest.matchers.nulls.beNull import io.kotest.matchers.should import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldNot @@ -33,39 +34,8 @@ object TypeIconTest : FunSpec({ } - context("combineWith") { - test("returns a template TypeIcon") { - val icon1 = TypeIcon(PlainIcon(), "text1", listOf(Color.GREEN)) - val icon2 = TypeIcon(PlainIcon(), "text2", listOf(Color.RED)) - - icon1.combineWith(icon2).base shouldBe Icons.TEMPLATE - } - - test("retains the text if it is the same for both icons") { - val icon1 = TypeIcon(PlainIcon(), "text", listOf(Color.PINK)) - val icon2 = TypeIcon(PlainIcon(), "text", listOf(Color.CYAN)) - - icon1.combineWith(icon2).text shouldBe "text" - } - - test("removes the text if it is different for the icons") { - val icon1 = TypeIcon(PlainIcon(), "text1", listOf(Color.GRAY)) - val icon2 = TypeIcon(PlainIcon(), "text2", listOf(Color.ORANGE)) - - icon1.combineWith(icon2).text shouldBe "" - } - - test("appends the colors of the combined icons") { - val icon1 = TypeIcon(PlainIcon(), "text1", listOf(Color.BLUE, Color.WHITE)) - val icon2 = TypeIcon(PlainIcon(), "text2", listOf(Color.RED, Color.PINK)) - - icon1.combineWith(icon2).colors shouldContainExactly listOf(Color.BLUE, Color.WHITE, Color.RED, Color.PINK) - } - } - - context("paintIcon") { - tags(NamedTag("Swing")) + tags(Tags.SWING) lateinit var image: BufferedImage @@ -98,6 +68,64 @@ object TypeIconTest : FunSpec({ image.getRGB(0, 0, 32, 32, null, 0, 32).filter { it != 0 } shouldNot beEmpty() } } + + + context("combine") { + test("returns `null` if no icons are given to combine") { + TypeIcon.combine(emptyList()) should beNull() + } + + test("returns a template icon for a single icon") { + val icons = listOf(TypeIcon(PlainIcon(), "text", listOf(Color.LIGHT_GRAY))) + + TypeIcon.combine(icons)!!.base shouldBe Icons.TEMPLATE + } + + test("returns a template icon for multiple icons") { + val icons = + listOf( + TypeIcon(PlainIcon(), "text1", listOf(Color.GREEN)), + TypeIcon(PlainIcon(), "text2", listOf(Color.RED)), + TypeIcon(PlainIcon(), "text3", listOf(Color.MAGENTA)), + ) + + TypeIcon.combine(icons)!!.base shouldBe Icons.TEMPLATE + } + + test("retains the text if it is the same for all icons") { + val icons = + listOf( + TypeIcon(PlainIcon(), "text", listOf(Color.PINK)), + TypeIcon(PlainIcon(), "text", listOf(Color.CYAN)), + TypeIcon(PlainIcon(), "text", listOf(Color.GREEN)), + ) + + TypeIcon.combine(icons)!!.text shouldBe "text" + } + + test("removes the text if it is not the same for all icons") { + val icons = + listOf( + TypeIcon(PlainIcon(), "text1", listOf(Color.GRAY)), + TypeIcon(PlainIcon(), "text2", listOf(Color.ORANGE)), + TypeIcon(PlainIcon(), "text2", listOf(Color.BLUE)), + ) + + TypeIcon.combine(icons)!!.text shouldBe "" + } + + test("appends the colors of the combined icons") { + val icons = + listOf( + TypeIcon(PlainIcon(), "text1", listOf(Color.BLUE, Color.WHITE)), + TypeIcon(PlainIcon(), "text2", listOf(Color.RED)), + TypeIcon(PlainIcon(), "text3", listOf(Color.PINK, Color.BLACK, Color.BLUE)), + ) + + TypeIcon.combine(icons)!!.colors shouldContainExactly + listOf(Color.BLUE, Color.WHITE, Color.RED, Color.PINK, Color.BLACK, Color.BLUE) + } + } }) /** @@ -105,7 +133,7 @@ object TypeIconTest : FunSpec({ */ object OverlayIconTest : FunSpec({ context("paintIcon") { - tags(NamedTag("Swing")) + tags(Tags.SWING) lateinit var image: BufferedImage @@ -207,7 +235,7 @@ object OverlayedIconTest : FunSpec({ context("paintIcon") { - tags(NamedTag("Swing")) + tags(Tags.SWING) lateinit var image: BufferedImage diff --git a/src/test/kotlin/com/fwdekker/randomness/SchemeEditorTest.kt b/src/test/kotlin/com/fwdekker/randomness/SchemeEditorTest.kt index 2d24c3413..019e839ad 100644 --- a/src/test/kotlin/com/fwdekker/randomness/SchemeEditorTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/SchemeEditorTest.kt @@ -4,6 +4,7 @@ import com.fwdekker.randomness.testhelpers.DummyDecoratorScheme import com.fwdekker.randomness.testhelpers.DummyDecoratorSchemeEditor import com.fwdekker.randomness.testhelpers.DummyScheme import com.fwdekker.randomness.testhelpers.DummySchemeEditor +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.afterNonContainer import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.fwdekker.randomness.testhelpers.guiGet @@ -13,7 +14,6 @@ import com.intellij.testFramework.fixtures.IdeaTestFixture import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory import com.intellij.ui.dsl.builder.bindText import com.intellij.ui.dsl.builder.panel -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.collections.shouldContainExactly import io.kotest.matchers.ints.shouldBeGreaterThanOrEqual @@ -33,7 +33,7 @@ import javax.swing.JCheckBox * Unit tests for [SchemeEditor]. */ object SchemeEditorTest : FunSpec({ - tags(NamedTag("IdeaFixture"), NamedTag("Swing")) + tags(Tags.EDITOR, Tags.IDEA_FIXTURE, Tags.SWING) lateinit var ideaFixture: IdeaTestFixture diff --git a/src/test/kotlin/com/fwdekker/randomness/SchemeTest.kt b/src/test/kotlin/com/fwdekker/randomness/SchemeTest.kt index fb3770986..8692295d9 100644 --- a/src/test/kotlin/com/fwdekker/randomness/SchemeTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/SchemeTest.kt @@ -2,8 +2,8 @@ package com.fwdekker.randomness import com.fwdekker.randomness.testhelpers.DummyDecoratorScheme import com.fwdekker.randomness.testhelpers.DummyScheme +import com.fwdekker.randomness.testhelpers.Tags import io.kotest.assertions.throwables.shouldThrow -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.collections.beEmpty import io.kotest.matchers.collections.shouldContainExactly @@ -18,7 +18,7 @@ import java.awt.Color * Unit tests for [Scheme]. */ object SchemeTest : FunSpec({ - tags(NamedTag("Scheme")) + tags(Tags.SCHEME) context("icon") { @@ -146,6 +146,9 @@ object SchemeTest : FunSpec({ * Unit tests for [DecoratorScheme]. */ object DecoratorSchemeTest : FunSpec({ + tags(Tags.SCHEME) + + context("generateStrings") { test("throws an exception if the decorator is invalid") { val decorator = DummyDecoratorScheme(enabled = true, valid = false) diff --git a/src/test/kotlin/com/fwdekker/randomness/StateTest.kt b/src/test/kotlin/com/fwdekker/randomness/StateTest.kt index 05febaf9a..10cc4eb36 100644 --- a/src/test/kotlin/com/fwdekker/randomness/StateTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/StateTest.kt @@ -1,7 +1,7 @@ package com.fwdekker.randomness import com.fwdekker.randomness.testhelpers.DummyState -import io.kotest.core.NamedTag +import com.fwdekker.randomness.testhelpers.Tags import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.collections.shouldHaveSize import io.kotest.matchers.shouldBe @@ -13,7 +13,7 @@ import io.kotest.matchers.types.shouldBeSameInstanceAs * Unit tests for [State]. */ object StateTest : FunSpec({ - tags(NamedTag("Scheme")) + tags(Tags.SCHEME) context("uuid") { diff --git a/src/test/kotlin/com/fwdekker/randomness/TimelyTest.kt b/src/test/kotlin/com/fwdekker/randomness/TimelyTest.kt index 74f02d868..a71214a3f 100644 --- a/src/test/kotlin/com/fwdekker/randomness/TimelyTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/TimelyTest.kt @@ -2,8 +2,10 @@ package com.fwdekker.randomness import com.fwdekker.randomness.Timely.GENERATOR_TIMEOUT import com.fwdekker.randomness.Timely.generateTimely +import com.fwdekker.randomness.testhelpers.matchBundle import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.should import io.kotest.matchers.shouldBe @@ -17,7 +19,7 @@ object TimelyTest : FunSpec({ test("throws an exception if the generator does not finish within time") { shouldThrow { generateTimely { Thread.sleep(GENERATOR_TIMEOUT + 1000L) } } - .message shouldBe Bundle("helpers.error.timed_out") + .message should matchBundle("helpers.error.timed_out") } test("throws an exception if the generator throws an exception") { diff --git a/src/test/kotlin/com/fwdekker/randomness/XmlHelpersTest.kt b/src/test/kotlin/com/fwdekker/randomness/XmlHelpersTest.kt index f1039503a..102531e75 100644 --- a/src/test/kotlin/com/fwdekker/randomness/XmlHelpersTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/XmlHelpersTest.kt @@ -3,6 +3,8 @@ package com.fwdekker.randomness import com.intellij.openapi.util.JDOMUtil import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.collections.shouldContainExactly +import io.kotest.matchers.nulls.beNull +import io.kotest.matchers.should import io.kotest.matchers.shouldBe @@ -55,7 +57,7 @@ object XmlHelpersTest : FunSpec({ """.trimIndent() ) - element.getContentByName("needle")?.name shouldBe null + element.getContentByName("needle")?.name should beNull() } test("returns `null` if multiple children have the given name") { @@ -70,7 +72,7 @@ object XmlHelpersTest : FunSpec({ """.trimIndent() ) - element.getContentByName("needle")?.name shouldBe null + element.getContentByName("needle")?.name should beNull() } } @@ -100,7 +102,7 @@ object XmlHelpersTest : FunSpec({ """.trimIndent() ) - element.getAttributeValueByName("needle") shouldBe null + element.getAttributeValueByName("needle") should beNull() } test("returns `null` if multiple children have the given name") { @@ -115,7 +117,7 @@ object XmlHelpersTest : FunSpec({ """.trimIndent() ) - element.getAttributeValueByName("needle") shouldBe null + element.getAttributeValueByName("needle") should beNull() } test("returns `null` if the child does not have a value attribute") { @@ -129,7 +131,7 @@ object XmlHelpersTest : FunSpec({ """.trimIndent() ) - element.getAttributeValueByName("needle") shouldBe null + element.getAttributeValueByName("needle") should beNull() } } @@ -161,7 +163,7 @@ object XmlHelpersTest : FunSpec({ """.trimIndent() ) - element.getAttributeValueByName("needle") shouldBe null + element.getAttributeValueByName("needle") should beNull() element.setAttributeValueByName("needle", "new-value") @@ -214,7 +216,7 @@ object XmlHelpersTest : FunSpec({ test("returns `null` if there are no children") { val element = JDOMUtil.load("") - element.getSingleContent() shouldBe null + element.getSingleContent() should beNull() } test("returns `null` if there are multiple children") { @@ -227,7 +229,7 @@ object XmlHelpersTest : FunSpec({ """.trimIndent() ) - element.getSingleContent() shouldBe null + element.getSingleContent() should beNull() } } @@ -291,7 +293,7 @@ object XmlHelpersTest : FunSpec({ """.trimIndent() ) - element.getContentByPath("wrong", null, "prong", null)?.name shouldBe null + element.getContentByPath("wrong", null, "prong", null)?.name should beNull() } } }) diff --git a/src/test/kotlin/com/fwdekker/randomness/affix/AffixDecoratorEditorTest.kt b/src/test/kotlin/com/fwdekker/randomness/affix/AffixDecoratorEditorTest.kt index 2a9d7ba5f..6e96cc9e1 100644 --- a/src/test/kotlin/com/fwdekker/randomness/affix/AffixDecoratorEditorTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/affix/AffixDecoratorEditorTest.kt @@ -2,6 +2,7 @@ package com.fwdekker.randomness.affix import com.fwdekker.randomness.editorApplyTestFactory import com.fwdekker.randomness.editorFieldsTestFactory +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.afterNonContainer import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.fwdekker.randomness.testhelpers.guiGet @@ -13,7 +14,6 @@ import com.intellij.testFramework.fixtures.IdeaTestFixture import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory import com.intellij.ui.layout.selected import io.kotest.assertions.throwables.shouldNotThrowAny -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import io.kotest.datatest.withData @@ -29,7 +29,7 @@ import javax.swing.JCheckBox * Unit tests for [AffixDecoratorEditor]. */ object AffixDecoratorEditorTest : FunSpec({ - tags(NamedTag("Editor"), NamedTag("IdeaFixture"), NamedTag("Swing")) + tags(Tags.EDITOR, Tags.IDEA_FIXTURE, Tags.SWING) lateinit var ideaFixture: IdeaTestFixture diff --git a/src/test/kotlin/com/fwdekker/randomness/affix/AffixDecoratorTest.kt b/src/test/kotlin/com/fwdekker/randomness/affix/AffixDecoratorTest.kt index 17e356732..74db1629f 100644 --- a/src/test/kotlin/com/fwdekker/randomness/affix/AffixDecoratorTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/affix/AffixDecoratorTest.kt @@ -1,8 +1,8 @@ package com.fwdekker.randomness.affix import com.fwdekker.randomness.stateDeepCopyTestFactory +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.shouldValidateAsBundle -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import io.kotest.datatest.withData @@ -13,7 +13,7 @@ import io.kotest.matchers.shouldBe * Unit tests for [AffixDecorator]. */ object AffixDecoratorTest : FunSpec({ - tags(NamedTag("Scheme")) + tags(Tags.SCHEME) context("generateStrings") { diff --git a/src/test/kotlin/com/fwdekker/randomness/array/ArrayDecoratorEditorTest.kt b/src/test/kotlin/com/fwdekker/randomness/array/ArrayDecoratorEditorTest.kt index 986e0bf36..4d571bc79 100644 --- a/src/test/kotlin/com/fwdekker/randomness/array/ArrayDecoratorEditorTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/array/ArrayDecoratorEditorTest.kt @@ -2,6 +2,7 @@ package com.fwdekker.randomness.array import com.fwdekker.randomness.editorApplyTestFactory import com.fwdekker.randomness.editorFieldsTestFactory +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.afterNonContainer import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.fwdekker.randomness.testhelpers.guiGet @@ -14,7 +15,6 @@ import com.fwdekker.randomness.testhelpers.valueProp import com.intellij.testFramework.fixtures.IdeaTestFixture import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory import com.intellij.ui.TitledSeparator -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import io.kotest.matchers.collections.beEmpty @@ -29,7 +29,7 @@ import javax.swing.JCheckBox * Unit tests for [ArrayDecoratorEditor]. */ object ArrayDecoratorEditorTest : FunSpec({ - tags(NamedTag("Editor"), NamedTag("IdeaFixture"), NamedTag("Swing")) + tags(Tags.EDITOR, Tags.IDEA_FIXTURE, Tags.SWING) lateinit var ideaFixture: IdeaTestFixture diff --git a/src/test/kotlin/com/fwdekker/randomness/array/ArrayDecoratorTest.kt b/src/test/kotlin/com/fwdekker/randomness/array/ArrayDecoratorTest.kt index 61f05437a..018e45bdb 100644 --- a/src/test/kotlin/com/fwdekker/randomness/array/ArrayDecoratorTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/array/ArrayDecoratorTest.kt @@ -2,8 +2,8 @@ package com.fwdekker.randomness.array import com.fwdekker.randomness.affix.AffixDecorator import com.fwdekker.randomness.stateDeepCopyTestFactory +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.shouldValidateAsBundle -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import io.kotest.datatest.withData @@ -15,7 +15,7 @@ import io.kotest.matchers.shouldBe * Unit tests for [ArrayDecorator]. */ object ArrayDecoratorTest : FunSpec({ - tags(NamedTag("Scheme")) + tags(Tags.SCHEME) context("generateStrings") { diff --git a/src/test/kotlin/com/fwdekker/randomness/datetime/DateTimeSchemeEditorTest.kt b/src/test/kotlin/com/fwdekker/randomness/datetime/DateTimeSchemeEditorTest.kt index d2ee06e8c..fa459d173 100644 --- a/src/test/kotlin/com/fwdekker/randomness/datetime/DateTimeSchemeEditorTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/datetime/DateTimeSchemeEditorTest.kt @@ -2,6 +2,7 @@ package com.fwdekker.randomness.datetime import com.fwdekker.randomness.editorApplyTestFactory import com.fwdekker.randomness.editorFieldsTestFactory +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.afterNonContainer import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.fwdekker.randomness.testhelpers.dateTimeProp @@ -12,7 +13,6 @@ import com.fwdekker.randomness.testhelpers.textProp import com.fwdekker.randomness.testhelpers.valueProp import com.intellij.testFramework.fixtures.IdeaTestFixture import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import io.kotest.matchers.shouldBe @@ -25,7 +25,7 @@ import org.assertj.swing.fixture.FrameFixture * Unit tests for [DateTimeSchemeEditor]. */ object DateTimeSchemeEditorTest : FunSpec({ - tags(NamedTag("Editor"), NamedTag("IdeaFixture"), NamedTag("Swing")) + tags(Tags.EDITOR, Tags.IDEA_FIXTURE, Tags.SWING) lateinit var ideaFixture: IdeaTestFixture diff --git a/src/test/kotlin/com/fwdekker/randomness/datetime/DateTimeSchemeTest.kt b/src/test/kotlin/com/fwdekker/randomness/datetime/DateTimeSchemeTest.kt index f867f1189..0a338a9e5 100644 --- a/src/test/kotlin/com/fwdekker/randomness/datetime/DateTimeSchemeTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/datetime/DateTimeSchemeTest.kt @@ -2,9 +2,9 @@ package com.fwdekker.randomness.datetime import com.fwdekker.randomness.integer.IntegerScheme import com.fwdekker.randomness.stateDeepCopyTestFactory +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.shouldValidateAsBundle import io.kotest.assertions.withClue -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import io.kotest.datatest.withData @@ -16,7 +16,7 @@ import io.kotest.matchers.shouldBe * Unit tests for [DateTimeScheme]. */ object DateTimeSchemeTest : FunSpec({ - tags(NamedTag("Scheme")) + tags(Tags.SCHEME) context("generateStrings") { diff --git a/src/test/kotlin/com/fwdekker/randomness/decimal/DecimalSchemeEditorTest.kt b/src/test/kotlin/com/fwdekker/randomness/decimal/DecimalSchemeEditorTest.kt index 0078f9b89..171c90ec9 100644 --- a/src/test/kotlin/com/fwdekker/randomness/decimal/DecimalSchemeEditorTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/decimal/DecimalSchemeEditorTest.kt @@ -2,6 +2,7 @@ package com.fwdekker.randomness.decimal import com.fwdekker.randomness.editorApplyTestFactory import com.fwdekker.randomness.editorFieldsTestFactory +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.afterNonContainer import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.fwdekker.randomness.testhelpers.guiGet @@ -12,7 +13,6 @@ import com.fwdekker.randomness.testhelpers.textProp import com.fwdekker.randomness.testhelpers.valueProp import com.intellij.testFramework.fixtures.IdeaTestFixture import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import org.assertj.swing.edt.FailOnThreadViolationRepaintManager @@ -24,7 +24,7 @@ import org.assertj.swing.fixture.FrameFixture * Unit tests for [DecimalSchemeEditor]. */ object DecimalSchemeEditorTest : FunSpec({ - tags(NamedTag("Editor"), NamedTag("IdeaFixture"), NamedTag("Swing")) + tags(Tags.EDITOR, Tags.IDEA_FIXTURE, Tags.SWING) lateinit var ideaFixture: IdeaTestFixture diff --git a/src/test/kotlin/com/fwdekker/randomness/decimal/DecimalSchemeTest.kt b/src/test/kotlin/com/fwdekker/randomness/decimal/DecimalSchemeTest.kt index 12afab892..b2d677b22 100644 --- a/src/test/kotlin/com/fwdekker/randomness/decimal/DecimalSchemeTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/decimal/DecimalSchemeTest.kt @@ -3,8 +3,8 @@ package com.fwdekker.randomness.decimal import com.fwdekker.randomness.affix.AffixDecorator import com.fwdekker.randomness.array.ArrayDecorator import com.fwdekker.randomness.stateDeepCopyTestFactory +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.shouldValidateAsBundle -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import io.kotest.datatest.withData @@ -15,7 +15,7 @@ import io.kotest.matchers.shouldBe * Unit tests for [DecimalScheme]. */ object DecimalSchemeTest : FunSpec({ - tags(NamedTag("Scheme")) + tags(Tags.SCHEME) context("generateStrings") { diff --git a/src/test/kotlin/com/fwdekker/randomness/fixedlength/FixedLengthDecoratorEditorTest.kt b/src/test/kotlin/com/fwdekker/randomness/fixedlength/FixedLengthDecoratorEditorTest.kt index f87112129..72ed6c6b1 100644 --- a/src/test/kotlin/com/fwdekker/randomness/fixedlength/FixedLengthDecoratorEditorTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/fixedlength/FixedLengthDecoratorEditorTest.kt @@ -2,6 +2,7 @@ package com.fwdekker.randomness.fixedlength import com.fwdekker.randomness.editorApplyTestFactory import com.fwdekker.randomness.editorFieldsTestFactory +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.afterNonContainer import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.fwdekker.randomness.testhelpers.guiGet @@ -12,7 +13,6 @@ import com.fwdekker.randomness.testhelpers.textProp import com.fwdekker.randomness.testhelpers.valueProp import com.intellij.testFramework.fixtures.IdeaTestFixture import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import org.assertj.swing.edt.FailOnThreadViolationRepaintManager @@ -24,7 +24,7 @@ import org.assertj.swing.fixture.FrameFixture * Unit tests for [FixedLengthDecoratorEditor]. */ object FixedLengthDecoratorEditorTest : FunSpec({ - tags(NamedTag("Editor"), NamedTag("IdeaFixture"), NamedTag("Swing")) + tags(Tags.EDITOR, Tags.IDEA_FIXTURE, Tags.SWING) lateinit var ideaFixture: IdeaTestFixture diff --git a/src/test/kotlin/com/fwdekker/randomness/fixedlength/FixedLengthDecoratorTest.kt b/src/test/kotlin/com/fwdekker/randomness/fixedlength/FixedLengthDecoratorTest.kt index 4e56ed05f..c57663a5a 100644 --- a/src/test/kotlin/com/fwdekker/randomness/fixedlength/FixedLengthDecoratorTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/fixedlength/FixedLengthDecoratorTest.kt @@ -1,8 +1,8 @@ package com.fwdekker.randomness.fixedlength import com.fwdekker.randomness.stateDeepCopyTestFactory +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.shouldValidateAsBundle -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import io.kotest.datatest.withData @@ -13,7 +13,7 @@ import io.kotest.matchers.shouldBe * Unit tests for [FixedLengthDecorator]. */ object FixedLengthDecoratorTest : FunSpec({ - tags(NamedTag("Scheme")) + tags(Tags.SCHEME) context("generateStrings") { diff --git a/src/test/kotlin/com/fwdekker/randomness/integer/IntegerSchemeEditorTest.kt b/src/test/kotlin/com/fwdekker/randomness/integer/IntegerSchemeEditorTest.kt index 898eec6a2..315cd9862 100644 --- a/src/test/kotlin/com/fwdekker/randomness/integer/IntegerSchemeEditorTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/integer/IntegerSchemeEditorTest.kt @@ -2,6 +2,7 @@ package com.fwdekker.randomness.integer import com.fwdekker.randomness.editorApplyTestFactory import com.fwdekker.randomness.editorFieldsTestFactory +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.afterNonContainer import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.fwdekker.randomness.testhelpers.guiGet @@ -13,7 +14,6 @@ import com.fwdekker.randomness.testhelpers.textProp import com.fwdekker.randomness.testhelpers.valueProp import com.intellij.testFramework.fixtures.IdeaTestFixture import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import io.kotest.datatest.withData @@ -26,7 +26,7 @@ import org.assertj.swing.fixture.FrameFixture * Unit tests for [IntegerSchemeEditor]. */ object IntegerSchemeEditorTest : FunSpec({ - tags(NamedTag("Editor"), NamedTag("IdeaFixture"), NamedTag("Swing")) + tags(Tags.EDITOR, Tags.IDEA_FIXTURE, Tags.SWING) lateinit var ideaFixture: IdeaTestFixture diff --git a/src/test/kotlin/com/fwdekker/randomness/integer/IntegerSchemeTest.kt b/src/test/kotlin/com/fwdekker/randomness/integer/IntegerSchemeTest.kt index 76010bc31..80cc15c26 100644 --- a/src/test/kotlin/com/fwdekker/randomness/integer/IntegerSchemeTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/integer/IntegerSchemeTest.kt @@ -4,9 +4,9 @@ import com.fwdekker.randomness.affix.AffixDecorator import com.fwdekker.randomness.array.ArrayDecorator import com.fwdekker.randomness.fixedlength.FixedLengthDecorator import com.fwdekker.randomness.stateDeepCopyTestFactory +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.shouldValidateAsBundle import io.kotest.assertions.withClue -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import io.kotest.datatest.withData @@ -18,7 +18,7 @@ import io.kotest.matchers.shouldBe * Unit tests for [IntegerScheme]. */ object IntegerSchemeTest : FunSpec({ - tags(NamedTag("Scheme")) + tags(Tags.SCHEME) context("generateStrings") { diff --git a/src/test/kotlin/com/fwdekker/randomness/string/StringSchemeEditorTest.kt b/src/test/kotlin/com/fwdekker/randomness/string/StringSchemeEditorTest.kt index 5ca3b21e0..3348c5daf 100644 --- a/src/test/kotlin/com/fwdekker/randomness/string/StringSchemeEditorTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/string/StringSchemeEditorTest.kt @@ -3,6 +3,7 @@ package com.fwdekker.randomness.string import com.fwdekker.randomness.CapitalizationMode import com.fwdekker.randomness.editorApplyTestFactory import com.fwdekker.randomness.editorFieldsTestFactory +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.afterNonContainer import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.fwdekker.randomness.testhelpers.guiGet @@ -13,7 +14,6 @@ import com.fwdekker.randomness.testhelpers.textProp import com.fwdekker.randomness.testhelpers.valueProp import com.intellij.testFramework.fixtures.IdeaTestFixture import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import org.assertj.swing.edt.FailOnThreadViolationRepaintManager @@ -25,7 +25,7 @@ import org.assertj.swing.fixture.FrameFixture * Unit tests for [StringSchemeEditor]. */ object StringSchemeEditorTest : FunSpec({ - tags(NamedTag("Editor"), NamedTag("IdeaFixture"), NamedTag("Swing")) + tags(Tags.EDITOR, Tags.IDEA_FIXTURE, Tags.SWING) lateinit var ideaFixture: IdeaTestFixture diff --git a/src/test/kotlin/com/fwdekker/randomness/string/StringSchemeTest.kt b/src/test/kotlin/com/fwdekker/randomness/string/StringSchemeTest.kt index 60f4d46e9..d37b21d0f 100644 --- a/src/test/kotlin/com/fwdekker/randomness/string/StringSchemeTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/string/StringSchemeTest.kt @@ -3,8 +3,8 @@ package com.fwdekker.randomness.string import com.fwdekker.randomness.CapitalizationMode import com.fwdekker.randomness.array.ArrayDecorator import com.fwdekker.randomness.stateDeepCopyTestFactory +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.shouldValidateAsBundle -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import io.kotest.datatest.withData @@ -15,7 +15,7 @@ import io.kotest.matchers.shouldBe * Unit tests for [StringScheme]. */ object StringSchemeTest : FunSpec({ - tags(NamedTag("Scheme")) + tags(Tags.SCHEME) context("isSimple") { diff --git a/src/test/kotlin/com/fwdekker/randomness/template/TemplateActionLoaderTest.kt b/src/test/kotlin/com/fwdekker/randomness/template/TemplateActionLoaderTest.kt index 7c2aab2bf..e385c9072 100644 --- a/src/test/kotlin/com/fwdekker/randomness/template/TemplateActionLoaderTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/template/TemplateActionLoaderTest.kt @@ -1,11 +1,11 @@ package com.fwdekker.randomness.template +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.afterNonContainer import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.intellij.openapi.actionSystem.ActionManager import com.intellij.testFramework.fixtures.IdeaTestFixture import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.collections.beEmpty import io.kotest.matchers.collections.shouldHaveAtLeastSize @@ -18,7 +18,7 @@ import io.kotest.matchers.shouldNot * Unit tests for [TemplateActionLoader]. */ object TemplateActionLoaderTest : FunSpec({ - tags(NamedTag("IdeaFixture")) + tags(Tags.IDEA_FIXTURE) lateinit var ideaFixture: IdeaTestFixture diff --git a/src/test/kotlin/com/fwdekker/randomness/template/TemplateActionTests.kt b/src/test/kotlin/com/fwdekker/randomness/template/TemplateActionTests.kt index 6126f49ba..db429b889 100644 --- a/src/test/kotlin/com/fwdekker/randomness/template/TemplateActionTests.kt +++ b/src/test/kotlin/com/fwdekker/randomness/template/TemplateActionTests.kt @@ -1,16 +1,16 @@ package com.fwdekker.randomness.template -import com.fwdekker.randomness.Bundle import com.fwdekker.randomness.Icons import com.fwdekker.randomness.OverlayIcon import com.fwdekker.randomness.OverlayedIcon import com.fwdekker.randomness.TypeIcon import com.fwdekker.randomness.testhelpers.DummyScheme +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.afterNonContainer import com.fwdekker.randomness.testhelpers.beforeNonContainer +import com.fwdekker.randomness.testhelpers.matchBundle import com.intellij.testFramework.fixtures.IdeaTestFixture import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import io.kotest.datatest.withData @@ -27,7 +27,7 @@ import java.awt.Color * Unit tests for [TemplateGroupAction]. */ object TemplateGroupActionTest : FunSpec({ - tags(NamedTag("IdeaFixture")) + tags(Tags.IDEA_FIXTURE) lateinit var ideaFixture: IdeaTestFixture @@ -132,7 +132,7 @@ object TemplateInsertActionTest : FunSpec({ * Unit tests for [TemplateSettingsAction]. */ object TemplateSettingsActionTest : FunSpec({ - tags(NamedTag("IdeaFixture")) + tags(Tags.IDEA_FIXTURE) lateinit var ideaFixture: IdeaTestFixture @@ -153,7 +153,7 @@ object TemplateSettingsActionTest : FunSpec({ test("uses a default text if the template is null") { val action = TemplateSettingsAction(template = null) - action.templatePresentation.text shouldBe Bundle("template.name.settings") + action.templatePresentation.text should matchBundle("template.name.settings") } test("uses the template's name if the template is not null") { @@ -185,11 +185,11 @@ object TemplateSettingsActionTest : FunSpec({ } test("uses the template's icon if the template is not null") { - val icon = TypeIcon(Icons.SCHEME, "war", listOf(Color.GREEN)) + val icon = TypeIcon(Icons.SCHEME, "wax", listOf(Color.GREEN)) val template = Template("subject", mutableListOf(DummyScheme().also { it.typeIcon = icon })) val action = TemplateSettingsAction(template) - (action.templatePresentation.icon as OverlayedIcon).base shouldBe icon + (action.templatePresentation.icon as OverlayedIcon).base shouldBe template.typeIcon } } } diff --git a/src/test/kotlin/com/fwdekker/randomness/template/TemplateEditorTest.kt b/src/test/kotlin/com/fwdekker/randomness/template/TemplateEditorTest.kt index c123d6f9a..68dcf63ab 100644 --- a/src/test/kotlin/com/fwdekker/randomness/template/TemplateEditorTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/template/TemplateEditorTest.kt @@ -1,12 +1,12 @@ package com.fwdekker.randomness.template import com.fwdekker.randomness.editorFieldsTestFactory +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.afterNonContainer import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.fwdekker.randomness.testhelpers.guiGet import com.fwdekker.randomness.testhelpers.prop import com.fwdekker.randomness.testhelpers.textProp -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import io.kotest.matchers.shouldBe @@ -19,7 +19,7 @@ import org.assertj.swing.fixture.FrameFixture * Unit tests for [TemplateEditor]. */ object TemplateEditorTest : FunSpec({ - tags(NamedTag("Editor"), NamedTag("IdeaFixture"), NamedTag("Swing")) + tags(Tags.EDITOR, Tags.IDEA_FIXTURE, Tags.SWING) lateinit var frame: FrameFixture diff --git a/src/test/kotlin/com/fwdekker/randomness/template/TemplateJTreeTest.kt b/src/test/kotlin/com/fwdekker/randomness/template/TemplateJTreeTest.kt index 83555329b..801cd68c0 100644 --- a/src/test/kotlin/com/fwdekker/randomness/template/TemplateJTreeTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/template/TemplateJTreeTest.kt @@ -4,6 +4,7 @@ import com.fwdekker.randomness.Scheme import com.fwdekker.randomness.Settings import com.fwdekker.randomness.setAll import com.fwdekker.randomness.testhelpers.DummyScheme +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.afterNonContainer import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.fwdekker.randomness.testhelpers.getActionButton @@ -15,7 +16,6 @@ import com.intellij.openapi.actionSystem.ActionToolbar import com.intellij.testFramework.fixtures.IdeaTestFixture import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory import io.kotest.assertions.throwables.shouldThrow -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.Row3 import io.kotest.data.row @@ -39,7 +39,7 @@ import org.assertj.swing.fixture.FrameFixture */ @Suppress("detekt:LargeClass") // Would be weird to split up given that CUT is not split up either object TemplateJTreeTest : FunSpec({ - tags(NamedTag("IdeaFixture"), NamedTag("Swing")) + tags(Tags.IDEA_FIXTURE, Tags.SWING) lateinit var ideaFixture: IdeaTestFixture @@ -291,38 +291,29 @@ object TemplateJTreeTest : FunSpec({ guiGet { (tree.getPathForRow(3).lastPathComponent as StateNode).state } shouldBe template guiGet { tree.isExpanded(3) } shouldBe true } - } - - context("expandAll") { - test("collapses all templates if an empty list is given") { - guiRun { tree.expandNodes(emptyList()) } - guiGet { tree.isExpanded(0) } shouldBe false - guiGet { tree.isExpanded(1) } shouldBe false - guiGet { tree.isExpanded(2) } shouldBe false - } + test( + "keeps collapsed nodes collapsed even if that template's original row index is larger than the new total " + + "row count" + ) { + guiRun { + currentList.templates.also { it.setAll(it.takeLast(1)) } + currentList.templates.single().schemes.also { it.setAll(it.take(1)) } + } - test("expands all templates if a full list is given") { - guiRun { tree.expandNodes(currentList.templates.map { it.uuid }) } + guiGet { tree.reload() } - guiGet { tree.isExpanded(0) } shouldBe true - guiGet { tree.isExpanded(3) } shouldBe true - guiGet { tree.isExpanded(5) } shouldBe true + guiGet { tree.isCollapsed(0) } shouldBe true } + } - test("expands the given nodes and collapses all other nodes") { - guiRun { - tree.collapseRow(0) - tree.collapseRow(1) - tree.expandRow(2) - } - guiGet { tree.rowCount } shouldBe 5 + context("expandAll") { + test("expands all templates") { + guiGet { tree.rowCount } shouldBe 3 - guiRun { tree.expandNodes(currentList.templates.take(2).map { it.uuid }) } + guiRun { tree.expandAll() } - guiGet { tree.isExpanded(0) } shouldBe true - guiGet { tree.isExpanded(3) } shouldBe true - guiGet { tree.isExpanded(5) } shouldBe false + guiGet { tree.rowCount } shouldBe 8 } } @@ -456,6 +447,25 @@ object TemplateJTreeTest : FunSpec({ tree.selectedScheme shouldBe currentList.templates[1].schemes[1] } + + test("keeps the parent expanded") { + guiRun { tree.selectedScheme = currentList.templates[1] } + + guiRun { tree.addScheme(DummyScheme()) } + + guiGet { tree.isExpanded(1) } shouldBe true + } + + test("expands the parent if it is not currently expanded") { + guiRun { + tree.removeScheme(currentList.templates[1].schemes[0]) + tree.selectedScheme = currentList.templates[1] + } + + guiRun { tree.addScheme(DummyScheme()) } + + guiGet { tree.isExpanded(1) } shouldBe true + } } } @@ -472,7 +482,7 @@ object TemplateJTreeTest : FunSpec({ tree.selectedScheme should beNull() } - test("selects the parent if the removed node had no siblings left") { + test("selects the parent if the removed node had no other siblings") { guiRun { tree.expandRow(1) } guiRun { tree.removeScheme(currentList.templates[1].schemes[0]) } @@ -487,6 +497,14 @@ object TemplateJTreeTest : FunSpec({ tree.selectedScheme?.name shouldBe "Scheme1" } + + test("keeps the parent expanded if it still has children") { + guiRun { tree.expandRow(0) } + + guiRun { tree.removeScheme(currentList.templates[0].schemes[0]) } + + guiGet { tree.isExpanded(0) } shouldBe true + } } context("replaceScheme") { @@ -508,20 +526,40 @@ object TemplateJTreeTest : FunSpec({ currentList.templates[2].schemes shouldContain newScheme } - test("retains the current expansion state") { + test("retains the current selection") { + guiRun { tree.selectedScheme = currentList.templates[2] } + + guiRun { tree.replaceScheme(currentList.templates[1].schemes[0], DummyScheme()) } + + guiGet { tree.selectedScheme } shouldBe currentList.templates[2] + } + + test("keeps the replaced template collapsed") { + val oldTemplate = currentList.templates[0] + val newTemplate = Template(schemes = mutableListOf(DummyScheme())).also { it.uuid = oldTemplate.uuid } + guiRun { tree.collapseRow(0) } + + guiRun { tree.replaceScheme(oldTemplate, newTemplate) } + + guiGet { tree.isCollapsed(0) } shouldBe true + } + + test("keeps the replaced template expanded") { + val oldTemplate = currentList.templates[0] + val newTemplate = Template(schemes = mutableListOf(DummyScheme())).also { it.uuid = oldTemplate.uuid } guiRun { tree.expandRow(0) } - guiRun { tree.replaceScheme(currentList.templates[0].schemes[1], DummyScheme()) } + guiRun { tree.replaceScheme(oldTemplate, newTemplate) } guiGet { tree.isExpanded(0) } shouldBe true } - test("retains the current selection") { - guiRun { tree.selectedScheme = currentList.templates[2] } + test("keeps the parent expanded") { + guiRun { tree.expandRow(0) } - tree.replaceScheme(currentList.templates[1].schemes[0], DummyScheme()) + guiRun { tree.replaceScheme(currentList.templates[0].schemes[1], DummyScheme()) } - guiGet { tree.selectedScheme } shouldBe currentList.templates[2] + guiGet { tree.isExpanded(0) } shouldBe true } } @@ -595,7 +633,7 @@ object TemplateJTreeTest : FunSpec({ guiGet { tree.isExpanded(0) } shouldBe true } - test("expands the scheme's new parent if the parent changes") { + test("if the parent changes, keeps the old parent expanded and expands the new parent") { guiRun { tree.collapseRow(1) tree.expandRow(0) @@ -604,6 +642,7 @@ object TemplateJTreeTest : FunSpec({ val scheme = currentList.templates[0].schemes[1] guiRun { tree.moveSchemeByOnePosition(scheme, moveDown = true) } + guiGet { tree.isExpanded(0) } shouldBe true tree.myModel.root.descendants[2].children shouldContain StateNode(scheme) guiGet { tree.isExpanded(2) } shouldBe true } @@ -623,7 +662,7 @@ object TemplateJTreeTest : FunSpec({ "move scheme between templates" to row({ currentList.templates[1].schemes[0] }, true, true), ) ) { (scheme, moveDown, expected) -> - guiRun { tree.expandNodes() } + guiRun { tree.expandAll() } tree.canMoveSchemeByOnePosition(scheme(), moveDown) shouldBe expected } diff --git a/src/test/kotlin/com/fwdekker/randomness/template/TemplateListConfigurableTest.kt b/src/test/kotlin/com/fwdekker/randomness/template/TemplateListConfigurableTest.kt index 85baf0fba..9fd30591c 100644 --- a/src/test/kotlin/com/fwdekker/randomness/template/TemplateListConfigurableTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/template/TemplateListConfigurableTest.kt @@ -1,6 +1,7 @@ package com.fwdekker.randomness.template import com.fwdekker.randomness.Settings +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.afterNonContainer import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.fwdekker.randomness.testhelpers.guiGet @@ -11,7 +12,6 @@ import com.intellij.openapi.options.ConfigurationException import com.intellij.testFramework.fixtures.IdeaTestFixture import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory import io.kotest.assertions.throwables.shouldThrow -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.should import io.kotest.matchers.shouldBe @@ -25,7 +25,7 @@ import org.assertj.swing.fixture.FrameFixture * Unit tests for [TemplateListConfigurable]. */ class TemplateListConfigurableTest : FunSpec({ - tags(NamedTag("IdeaFixture")) + tags(Tags.IDEA_FIXTURE) lateinit var ideaFixture: IdeaTestFixture diff --git a/src/test/kotlin/com/fwdekker/randomness/template/TemplateListEditorTest.kt b/src/test/kotlin/com/fwdekker/randomness/template/TemplateListEditorTest.kt index 95079a658..61a0d1517 100644 --- a/src/test/kotlin/com/fwdekker/randomness/template/TemplateListEditorTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/template/TemplateListEditorTest.kt @@ -8,6 +8,7 @@ import com.fwdekker.randomness.integer.IntegerScheme import com.fwdekker.randomness.setAll import com.fwdekker.randomness.string.StringScheme import com.fwdekker.randomness.testhelpers.DummyScheme +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.afterNonContainer import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.fwdekker.randomness.testhelpers.guiGet @@ -20,7 +21,6 @@ import com.intellij.openapi.util.Disposer import com.intellij.testFramework.fixtures.IdeaTestFixture import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory import io.kotest.assertions.throwables.shouldThrow -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.Row2 import io.kotest.data.row @@ -40,7 +40,7 @@ import org.assertj.swing.fixture.FrameFixture * Unit tests for [TemplateListEditor]. */ object TemplateListEditorTest : FunSpec({ - tags(NamedTag("Editor"), NamedTag("IdeaFixture"), NamedTag("Swing")) + tags(Tags.EDITOR, Tags.IDEA_FIXTURE, Tags.SWING) lateinit var ideaFixture: IdeaTestFixture @@ -240,15 +240,15 @@ object TemplateListEditorTest : FunSpec({ guiRun { frame.tree().target().setSelectionRow(1) frame.spinner("minValue").target().value = 7L - frame.tree().target().setSelectionRow(3) } - guiRun { editor.reset() } - guiRun { - frame.tree().target().setSelectionRow(1) - frame.spinner("minValue").target().value shouldBe 0L + frame.tree().target().setSelectionRow(3) + editor.reset() } + + guiRun { frame.tree().target().setSelectionRow(1) } + guiGet { frame.spinner("minValue").target().value } shouldBe 0L } } }) diff --git a/src/test/kotlin/com/fwdekker/randomness/template/TemplateReferenceEditorTest.kt b/src/test/kotlin/com/fwdekker/randomness/template/TemplateReferenceEditorTest.kt index 7f9c32471..61804d774 100644 --- a/src/test/kotlin/com/fwdekker/randomness/template/TemplateReferenceEditorTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/template/TemplateReferenceEditorTest.kt @@ -4,6 +4,7 @@ import com.fwdekker.randomness.CapitalizationMode import com.fwdekker.randomness.Settings import com.fwdekker.randomness.editorFieldsTestFactory import com.fwdekker.randomness.testhelpers.DummyScheme +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.afterNonContainer import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.fwdekker.randomness.testhelpers.guiGet @@ -14,10 +15,11 @@ import com.fwdekker.randomness.testhelpers.textProp import com.fwdekker.randomness.testhelpers.valueProp import com.intellij.testFramework.fixtures.IdeaTestFixture import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import io.kotest.matchers.collections.shouldNotContain +import io.kotest.matchers.nulls.beNull +import io.kotest.matchers.should import io.kotest.matchers.shouldBe import org.assertj.swing.edt.FailOnThreadViolationRepaintManager import org.assertj.swing.fixture.Containers @@ -28,7 +30,7 @@ import org.assertj.swing.fixture.FrameFixture * Unit tests for [TemplateReferenceEditor]. */ object TemplateReferenceEditorTest : FunSpec({ - tags(NamedTag("Editor"), NamedTag("IdeaFixture"), NamedTag("Swing")) + tags(Tags.EDITOR, Tags.IDEA_FIXTURE, Tags.SWING) lateinit var ideaFixture: IdeaTestFixture @@ -76,7 +78,7 @@ object TemplateReferenceEditorTest : FunSpec({ reference.template = null guiRun { editor.reset() } - guiGet { frame.comboBox("template").itemProp().get() } shouldBe null + guiGet { frame.comboBox("template").itemProp().get() } should beNull() } test("does not load the reference's parent as a selectable option") { diff --git a/src/test/kotlin/com/fwdekker/randomness/template/TemplateReferenceTest.kt b/src/test/kotlin/com/fwdekker/randomness/template/TemplateReferenceTest.kt index fcffceb65..8cf084344 100644 --- a/src/test/kotlin/com/fwdekker/randomness/template/TemplateReferenceTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/template/TemplateReferenceTest.kt @@ -1,16 +1,16 @@ package com.fwdekker.randomness.template -import com.fwdekker.randomness.Bundle import com.fwdekker.randomness.CapitalizationMode import com.fwdekker.randomness.OverlayIcon import com.fwdekker.randomness.Settings import com.fwdekker.randomness.setAll import com.fwdekker.randomness.stateDeepCopyTestFactory import com.fwdekker.randomness.testhelpers.DummyScheme +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.beforeNonContainer +import com.fwdekker.randomness.testhelpers.matchBundle import com.fwdekker.randomness.testhelpers.shouldValidateAsBundle import io.kotest.assertions.throwables.shouldThrow -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import io.kotest.datatest.withData @@ -25,7 +25,7 @@ import io.kotest.matchers.shouldNot * Unit tests for [TemplateReference]. */ object TemplateReferenceTest : FunSpec({ - tags(NamedTag("Scheme")) + tags(Tags.SCHEME) lateinit var list: TemplateList @@ -48,7 +48,7 @@ object TemplateReferenceTest : FunSpec({ test("returns an alternative name if no template is set") { reference.template = null - reference.name shouldBe Bundle("reference.title") + reference.name should matchBundle("reference.title") } test("returns the referenced template's name with brackets") { diff --git a/src/test/kotlin/com/fwdekker/randomness/template/TemplateTest.kt b/src/test/kotlin/com/fwdekker/randomness/template/TemplateTest.kt index acd6b2cfd..6fb831656 100644 --- a/src/test/kotlin/com/fwdekker/randomness/template/TemplateTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/template/TemplateTest.kt @@ -2,16 +2,17 @@ package com.fwdekker.randomness.template import com.fwdekker.randomness.CapitalizationMode import com.fwdekker.randomness.DataGenerationException +import com.fwdekker.randomness.Icons import com.fwdekker.randomness.Settings import com.fwdekker.randomness.array.ArrayDecorator import com.fwdekker.randomness.integer.IntegerScheme import com.fwdekker.randomness.stateDeepCopyTestFactory import com.fwdekker.randomness.string.StringScheme import com.fwdekker.randomness.testhelpers.DummyScheme +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.shouldValidateAsBundle import com.fwdekker.randomness.word.WordScheme import io.kotest.assertions.throwables.shouldThrow -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import io.kotest.datatest.withData @@ -26,15 +27,14 @@ import kotlin.random.Random * Unit tests for [Template]. */ object TemplateTest : FunSpec({ - tags(NamedTag("Scheme")) + tags(Tags.SCHEME) context("typeIcon") { - test("returns the single scheme's icon if that scheme has an icon") { - val scheme = IntegerScheme() - val template = Template(schemes = mutableListOf(scheme)) + test("returns the default icon if the template contains no schemes") { + val template = Template() - template.typeIcon shouldBe scheme.typeIcon + template.typeIcon shouldBe Template.DEFAULT_ICON } test("returns the default icon if the single scheme has no icon") { @@ -44,10 +44,13 @@ object TemplateTest : FunSpec({ template.typeIcon shouldBe Template.DEFAULT_ICON } - test("returns the default icon if no scheme is present") { - val template = Template() + test("returns a template version of the single scheme's TypeIcon") { + val scheme = IntegerScheme() + val template = Template(schemes = mutableListOf(scheme)) - template.typeIcon shouldBe Template.DEFAULT_ICON + template.typeIcon.base shouldBe Icons.TEMPLATE + template.typeIcon.text shouldBe scheme.typeIcon.text + template.typeIcon.colors shouldBe scheme.typeIcon.colors } test("returns the scheme's combined icon if multiple are present") { diff --git a/src/test/kotlin/com/fwdekker/randomness/testhelpers/DummySchemeTest.kt b/src/test/kotlin/com/fwdekker/randomness/testhelpers/DummySchemeTest.kt index 49f40c95f..0e3a62711 100644 --- a/src/test/kotlin/com/fwdekker/randomness/testhelpers/DummySchemeTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/testhelpers/DummySchemeTest.kt @@ -9,6 +9,9 @@ import io.kotest.matchers.shouldNotBe * Non-comprehensive tests and sanity checks for [DummyScheme]. */ object DummySchemeTest : FunSpec({ + tags(Tags.SCHEME) + + test("does not equal another fresh instance") { DummyScheme() shouldNotBe DummyScheme() } diff --git a/src/test/kotlin/com/fwdekker/randomness/testhelpers/Tags.kt b/src/test/kotlin/com/fwdekker/randomness/testhelpers/Tags.kt new file mode 100644 index 000000000..7362b8721 --- /dev/null +++ b/src/test/kotlin/com/fwdekker/randomness/testhelpers/Tags.kt @@ -0,0 +1,31 @@ +package com.fwdekker.randomness.testhelpers + +import io.kotest.core.NamedTag + + +/** + * Tags for Kotest-based tags for filtering tests. + * + * See the project's README for more information. + */ +object Tags { + /** + * Tests for [com.fwdekker.randomness.SchemeEditor]s. + */ + val EDITOR = NamedTag("Editor") + + /** + * Tests that rely on setting up an IDE fixture. + */ + val IDEA_FIXTURE = NamedTag("IdeaFixture") + + /** + * Tests for [com.fwdekker.randomness.Scheme]s. + */ + val SCHEME = NamedTag("Scheme") + + /** + * Tests that rely on accessing Swing components. + */ + val SWING = NamedTag("Swing") +} diff --git a/src/test/kotlin/com/fwdekker/randomness/ui/JDateTimeFieldTest.kt b/src/test/kotlin/com/fwdekker/randomness/ui/JDateTimeFieldTest.kt index 8abab2a22..cbc3d6e1a 100644 --- a/src/test/kotlin/com/fwdekker/randomness/ui/JDateTimeFieldTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/ui/JDateTimeFieldTest.kt @@ -1,13 +1,14 @@ package com.fwdekker.randomness.ui -import com.fwdekker.randomness.Bundle +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.fwdekker.randomness.testhelpers.guiGet import com.fwdekker.randomness.testhelpers.guiRun +import com.fwdekker.randomness.testhelpers.matchBundle import com.github.sisyphsu.dateparser.DateParserUtils import io.kotest.assertions.throwables.shouldThrow -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.should import io.kotest.matchers.shouldBe import org.assertj.swing.edt.FailOnThreadViolationRepaintManager import java.text.ParseException @@ -19,7 +20,7 @@ import java.time.Month * Unit tests for [JDateTimeField]. */ object JDateTimeFieldTest : FunSpec({ - tags(NamedTag("Swing")) + tags(Tags.SWING) lateinit var field: JDateTimeField @@ -47,7 +48,7 @@ object JDateTimeFieldTest : FunSpec({ context("set") { test("throws an error if a non-date-time is set") { shouldThrow { guiRun { field.setValue("invalid") } } - .message shouldBe Bundle("datetime_field.error.invalid_type") + .message should matchBundle("datetime_field.error.invalid_type") } } @@ -98,7 +99,7 @@ object JDateTimeFieldTest : FunSpec({ shouldThrow { field.text = null field.commitEdit() - }.message shouldBe Bundle("datetime_field.error.empty_string") + }.message should matchBundle("datetime_field.error.empty_string") } } @@ -107,7 +108,7 @@ object JDateTimeFieldTest : FunSpec({ shouldThrow { field.text = "" field.commitEdit() - }.message shouldBe Bundle("datetime_field.error.empty_string") + }.message should matchBundle("datetime_field.error.empty_string") } } diff --git a/src/test/kotlin/com/fwdekker/randomness/ui/JNumberSpinnerTest.kt b/src/test/kotlin/com/fwdekker/randomness/ui/JNumberSpinnerTest.kt index da6bae9e2..5c555ef35 100644 --- a/src/test/kotlin/com/fwdekker/randomness/ui/JNumberSpinnerTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/ui/JNumberSpinnerTest.kt @@ -1,9 +1,9 @@ package com.fwdekker.randomness.ui +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.guiGet import com.fwdekker.randomness.testhelpers.guiRun import io.kotest.assertions.throwables.shouldThrow -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.nulls.beNull import io.kotest.matchers.should @@ -16,7 +16,7 @@ import javax.swing.JSpinner * Unit tests for [JNumberSpinner]. */ object JNumberSpinnerTest : FunSpec({ - tags(NamedTag("Swing")) + tags(Tags.SWING) beforeContainer { @@ -59,7 +59,7 @@ object JNumberSpinnerTest : FunSpec({ * Unit tests for [bindSpinners]. */ object BindSpinnersTest : FunSpec({ - tags(NamedTag("Swing")) + tags(Tags.SWING) beforeContainer { @@ -104,7 +104,7 @@ object BindSpinnersTest : FunSpec({ * Unit tests for [JDoubleSpinner]. */ object JDoubleSpinnerTest : FunSpec({ - tags(NamedTag("Swing")) + tags(Tags.SWING) beforeContainer { @@ -157,7 +157,7 @@ object JDoubleSpinnerTest : FunSpec({ * Unit tests for [JLongSpinner]. */ object JLongSpinnerTest : FunSpec({ - tags(NamedTag("Swing")) + tags(Tags.SWING) beforeContainer { @@ -210,7 +210,7 @@ object JLongSpinnerTest : FunSpec({ * Unit tests for [JIntSpinner]. */ object JIntSpinnerTest : FunSpec({ - tags(NamedTag("Swing")) + tags(Tags.SWING) beforeContainer { diff --git a/src/test/kotlin/com/fwdekker/randomness/ui/ListenerHelpersTest.kt b/src/test/kotlin/com/fwdekker/randomness/ui/ListenerHelpersTest.kt index e18427b39..aa85f8824 100644 --- a/src/test/kotlin/com/fwdekker/randomness/ui/ListenerHelpersTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/ui/ListenerHelpersTest.kt @@ -1,12 +1,12 @@ package com.fwdekker.randomness.ui import com.fwdekker.randomness.testhelpers.DummySchemeEditor +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.fwdekker.randomness.testhelpers.guiGet import com.fwdekker.randomness.testhelpers.guiRun import com.intellij.openapi.ui.ComboBox import com.intellij.ui.dsl.builder.panel -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.Row2 import io.kotest.data.row @@ -30,7 +30,7 @@ import javax.swing.tree.MutableTreeNode * Unit tests for extension functions in `ListenerHelpersKt`. */ object ListenerHelpersTest : FunSpec({ - tags(NamedTag("Swing")) + tags(Tags.SWING) var listenerInvoked = false @@ -75,7 +75,7 @@ object ListenerHelpersTest : FunSpec({ { PlainDocument().also { it.insertString(0, "text", null) } }, { (it as PlainDocument).replace(2, 1, "y", null) }, ), - // `JBDocument` is excluded because setting up the correct fixtures is very difficult + // [JBDocument] is excluded because setting up the correct fixtures is very difficult "JComboBox: Select different item" to row( { ComboBox(arrayOf("item1", "item2")) }, diff --git a/src/test/kotlin/com/fwdekker/randomness/ui/PreviewPanelTest.kt b/src/test/kotlin/com/fwdekker/randomness/ui/PreviewPanelTest.kt index 37e36d6b4..4c27ba0bb 100644 --- a/src/test/kotlin/com/fwdekker/randomness/ui/PreviewPanelTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/ui/PreviewPanelTest.kt @@ -2,6 +2,7 @@ package com.fwdekker.randomness.ui import com.fwdekker.randomness.Bundle import com.fwdekker.randomness.testhelpers.DummyScheme +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.afterNonContainer import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.fwdekker.randomness.testhelpers.find @@ -12,7 +13,6 @@ import com.intellij.openapi.util.Disposer import com.intellij.testFramework.fixtures.IdeaTestFixture import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory import com.intellij.ui.InplaceButton -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldNotBe @@ -25,7 +25,7 @@ import org.assertj.swing.fixture.FrameFixture * Unit tests for [PreviewPanel]. */ object PreviewPanelTest : FunSpec({ - tags(NamedTag("IdeaFixture"), NamedTag("Swing")) + tags(Tags.IDEA_FIXTURE, Tags.SWING) lateinit var ideaFixture: IdeaTestFixture diff --git a/src/test/kotlin/com/fwdekker/randomness/uuid/UuidSchemeEditorTest.kt b/src/test/kotlin/com/fwdekker/randomness/uuid/UuidSchemeEditorTest.kt index 7c6326c24..489102971 100644 --- a/src/test/kotlin/com/fwdekker/randomness/uuid/UuidSchemeEditorTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/uuid/UuidSchemeEditorTest.kt @@ -2,6 +2,7 @@ package com.fwdekker.randomness.uuid import com.fwdekker.randomness.editorApplyTestFactory import com.fwdekker.randomness.editorFieldsTestFactory +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.afterNonContainer import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.fwdekker.randomness.testhelpers.guiGet @@ -12,7 +13,6 @@ import com.fwdekker.randomness.testhelpers.textProp import com.fwdekker.randomness.testhelpers.valueProp import com.intellij.testFramework.fixtures.IdeaTestFixture import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import org.assertj.swing.edt.FailOnThreadViolationRepaintManager @@ -24,7 +24,7 @@ import org.assertj.swing.fixture.FrameFixture * Unit tests for [UuidSchemeEditor]. */ object UuidSchemeEditorTest : FunSpec({ - tags(NamedTag("Editor"), NamedTag("IdeaFixture"), NamedTag("Swing")) + tags(Tags.EDITOR, Tags.IDEA_FIXTURE, Tags.SWING) lateinit var ideaFixture: IdeaTestFixture diff --git a/src/test/kotlin/com/fwdekker/randomness/uuid/UuidSchemeTest.kt b/src/test/kotlin/com/fwdekker/randomness/uuid/UuidSchemeTest.kt index e5935fb43..11a0dfa66 100644 --- a/src/test/kotlin/com/fwdekker/randomness/uuid/UuidSchemeTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/uuid/UuidSchemeTest.kt @@ -3,8 +3,8 @@ package com.fwdekker.randomness.uuid import com.fwdekker.randomness.affix.AffixDecorator import com.fwdekker.randomness.array.ArrayDecorator import com.fwdekker.randomness.stateDeepCopyTestFactory +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.shouldValidateAsBundle -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import io.kotest.datatest.withData @@ -22,7 +22,7 @@ import io.kotest.matchers.string.shouldNotContain * Unit tests for [UuidScheme]. */ object UuidSchemeTest : FunSpec({ - tags(NamedTag("Scheme")) + tags(Tags.SCHEME) context("generateStrings") { diff --git a/src/test/kotlin/com/fwdekker/randomness/word/DefaultWordListTest.kt b/src/test/kotlin/com/fwdekker/randomness/word/DefaultWordListTest.kt index e70c1fca7..305894f10 100644 --- a/src/test/kotlin/com/fwdekker/randomness/word/DefaultWordListTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/word/DefaultWordListTest.kt @@ -1,14 +1,13 @@ package com.fwdekker.randomness.word -import com.fwdekker.randomness.Bundle import com.fwdekker.randomness.testhelpers.beforeNonContainer +import com.fwdekker.randomness.testhelpers.matchBundle import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.collections.beEmpty import io.kotest.matchers.collections.shouldContainExactly import io.kotest.matchers.longs.shouldBeLessThan import io.kotest.matchers.should -import io.kotest.matchers.shouldBe import java.io.IOException import kotlin.system.measureNanoTime @@ -26,7 +25,7 @@ object DefaultWordListTest : FunSpec({ test("throws an exception if the file does not exist") { val list = DefaultWordList("name", "word-lists/does-not-exist.txt") - shouldThrow { list.words }.message shouldBe Bundle("word_list.error.file_not_found") + shouldThrow { list.words }.message should matchBundle("word_list.error.file_not_found") } test("returns an empty list of words if the file is empty") { @@ -52,7 +51,7 @@ object DefaultWordListTest : FunSpec({ val list = DefaultWordList("name", "word-lists/does-not-exist.txt") shouldThrow { list.words } - shouldThrow { list.words }.message shouldBe Bundle("word_list.error.file_not_found") + .message should matchBundle("word_list.error.file_not_found") } test("returns words quicker if read again from the same instance") { diff --git a/src/test/kotlin/com/fwdekker/randomness/word/WordSchemeEditorTest.kt b/src/test/kotlin/com/fwdekker/randomness/word/WordSchemeEditorTest.kt index 72e5ef568..c9298adbb 100644 --- a/src/test/kotlin/com/fwdekker/randomness/word/WordSchemeEditorTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/word/WordSchemeEditorTest.kt @@ -3,6 +3,7 @@ package com.fwdekker.randomness.word import com.fwdekker.randomness.CapitalizationMode import com.fwdekker.randomness.editorApplyTestFactory import com.fwdekker.randomness.editorFieldsTestFactory +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.afterNonContainer import com.fwdekker.randomness.testhelpers.beforeNonContainer import com.fwdekker.randomness.testhelpers.find @@ -18,7 +19,6 @@ import com.intellij.openapi.editor.impl.EditorComponentImpl import com.intellij.openapi.util.Disposer import com.intellij.testFramework.fixtures.IdeaTestFixture import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import io.kotest.matchers.collections.shouldContainExactly @@ -32,7 +32,7 @@ import org.assertj.swing.fixture.FrameFixture * Unit tests for [WordSchemeEditor]. */ object WordSchemeEditorTest : FunSpec({ - tags(NamedTag("Editor"), NamedTag("IdeaFixture"), NamedTag("Swing")) + tags(Tags.EDITOR, Tags.IDEA_FIXTURE, Tags.SWING) lateinit var ideaFixture: IdeaTestFixture diff --git a/src/test/kotlin/com/fwdekker/randomness/word/WordSchemeTest.kt b/src/test/kotlin/com/fwdekker/randomness/word/WordSchemeTest.kt index 9664530fa..74fe3d23e 100644 --- a/src/test/kotlin/com/fwdekker/randomness/word/WordSchemeTest.kt +++ b/src/test/kotlin/com/fwdekker/randomness/word/WordSchemeTest.kt @@ -4,8 +4,8 @@ import com.fwdekker.randomness.CapitalizationMode import com.fwdekker.randomness.affix.AffixDecorator import com.fwdekker.randomness.array.ArrayDecorator import com.fwdekker.randomness.stateDeepCopyTestFactory +import com.fwdekker.randomness.testhelpers.Tags import com.fwdekker.randomness.testhelpers.shouldValidateAsBundle -import io.kotest.core.NamedTag import io.kotest.core.spec.style.FunSpec import io.kotest.data.row import io.kotest.datatest.withData @@ -16,7 +16,7 @@ import io.kotest.matchers.shouldBe * Unit tests for [WordScheme]. */ object WordSchemeTest : FunSpec({ - tags(NamedTag("Scheme")) + tags(Tags.SCHEME) context("generateStrings") {