Skip to content

Commit

Permalink
Reorganise test helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
FWDekker committed Sep 16, 2023
1 parent 9db39ae commit f144fce
Show file tree
Hide file tree
Showing 55 changed files with 377 additions and 301 deletions.
2 changes: 1 addition & 1 deletion .config/detekt/.detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ complexity:
active: false
# [Exception] Acceptable for helper files.
TooManyFunctions:
excludes: '**/*Helper.kt'
excludes: '**/*Helpers.kt'

formatting:
# [Disagree] Acceptable for many short arguments.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ fun addChangeListenerTo(vararg components: Any, listener: () -> Unit) {
component.addActionListener { listener() }
addChangeListenerTo(component.editor.editorComponent, listener = listener)
}

is JSpinner -> component.addChangeListener { listener() }
is JTextComponent -> addChangeListenerTo(component.document, listener = listener)
is JTree -> {
component.model.addTreeModelListener(SimpleTreeModelListener { listener() })
component.addTreeSelectionListener { listener() }
}

is SchemeEditor<*> -> component.addChangeListener(listener)
else -> Unit
}
Expand Down
143 changes: 0 additions & 143 deletions src/test/kotlin/com/fwdekker/randomness/AssertJHelper.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.fwdekker.randomness

import com.fwdekker.randomness.testhelpers.guiRun
import com.intellij.ui.dsl.builder.MutableProperty
import io.kotest.assertions.withClue
import io.kotest.core.factory.TestFactory
Expand Down
2 changes: 2 additions & 0 deletions src/test/kotlin/com/fwdekker/randomness/ErrorReporterTest.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.fwdekker.randomness

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
Expand Down
2 changes: 2 additions & 0 deletions src/test/kotlin/com/fwdekker/randomness/IconsTest.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.fwdekker.randomness

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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.fwdekker.randomness

import com.fwdekker.randomness.testhelpers.DummyInsertAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.actionSystem.Presentation
Expand Down
8 changes: 8 additions & 0 deletions src/test/kotlin/com/fwdekker/randomness/SchemeEditorTest.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
package com.fwdekker.randomness

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.afterNonContainer
import com.fwdekker.randomness.testhelpers.beforeNonContainer
import com.fwdekker.randomness.testhelpers.guiGet
import com.fwdekker.randomness.testhelpers.guiRun
import com.fwdekker.randomness.ui.withName
import com.intellij.testFramework.fixtures.IdeaTestFixture
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
Expand Down
2 changes: 2 additions & 0 deletions src/test/kotlin/com/fwdekker/randomness/SchemeTest.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.fwdekker.randomness

import com.fwdekker.randomness.testhelpers.DummyDecoratorScheme
import com.fwdekker.randomness.testhelpers.DummyScheme
import io.kotest.assertions.throwables.shouldThrow
import io.kotest.core.NamedTag
import io.kotest.core.spec.style.FunSpec
Expand Down
2 changes: 2 additions & 0 deletions src/test/kotlin/com/fwdekker/randomness/SettingsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.fwdekker.randomness

import com.fwdekker.randomness.template.Template
import com.fwdekker.randomness.template.TemplateList
import com.fwdekker.randomness.testhelpers.DummyState
import com.fwdekker.randomness.testhelpers.shouldValidateAsBundle
import io.kotest.assertions.throwables.shouldThrow
import io.kotest.core.spec.style.FunSpec
import io.kotest.data.row
Expand Down
1 change: 1 addition & 0 deletions src/test/kotlin/com/fwdekker/randomness/StateTest.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.fwdekker.randomness

import com.fwdekker.randomness.testhelpers.DummyState
import io.kotest.core.NamedTag
import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.collections.shouldContainExactly
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.fwdekker.randomness

import com.fwdekker.randomness.testhelpers.beforeNonContainer
import io.kotest.core.spec.style.funSpec
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.fwdekker.randomness.affix

import com.fwdekker.randomness.afterNonContainer
import com.fwdekker.randomness.beforeNonContainer
import com.fwdekker.randomness.editorApplyTestFactory
import com.fwdekker.randomness.editorFieldsTestFactory
import com.fwdekker.randomness.guiGet
import com.fwdekker.randomness.guiRun
import com.fwdekker.randomness.prop
import com.fwdekker.randomness.requireEnabledIs
import com.fwdekker.randomness.textProp
import com.fwdekker.randomness.testhelpers.afterNonContainer
import com.fwdekker.randomness.testhelpers.beforeNonContainer
import com.fwdekker.randomness.testhelpers.guiGet
import com.fwdekker.randomness.testhelpers.guiRun
import com.fwdekker.randomness.testhelpers.prop
import com.fwdekker.randomness.testhelpers.requireEnabledIs
import com.fwdekker.randomness.testhelpers.textProp
import com.intellij.testFramework.fixtures.IdeaTestFixture
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
import com.intellij.ui.layout.selected
Expand Down Expand Up @@ -113,7 +113,7 @@ object AffixDecoratorEditorTest : FunSpec({
row(true, true, true, true),
)
) { (predicateState, checkboxState, expectedCheckboxEnabled, expectedDescriptorEnabled) ->
val predicate = if (predicateState == null) null else toggle.selected
val predicate = predicateState?.let { toggle.selected }

frame.cleanUp()
editor = guiGet { AffixDecoratorEditor(scheme, presets = listOf("."), enabledIf = predicate) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.fwdekker.randomness.affix

import com.fwdekker.randomness.shouldValidateAsBundle
import com.fwdekker.randomness.stateDeepCopyTestFactory
import com.fwdekker.randomness.testhelpers.shouldValidateAsBundle
import io.kotest.core.NamedTag
import io.kotest.core.spec.style.FunSpec
import io.kotest.data.row
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.fwdekker.randomness.array

import com.fwdekker.randomness.afterNonContainer
import com.fwdekker.randomness.beforeNonContainer
import com.fwdekker.randomness.editorApplyTestFactory
import com.fwdekker.randomness.editorFieldsTestFactory
import com.fwdekker.randomness.guiGet
import com.fwdekker.randomness.guiRun
import com.fwdekker.randomness.isSelectedProp
import com.fwdekker.randomness.matcher
import com.fwdekker.randomness.prop
import com.fwdekker.randomness.textProp
import com.fwdekker.randomness.valueProp
import com.fwdekker.randomness.testhelpers.afterNonContainer
import com.fwdekker.randomness.testhelpers.beforeNonContainer
import com.fwdekker.randomness.testhelpers.guiGet
import com.fwdekker.randomness.testhelpers.guiRun
import com.fwdekker.randomness.testhelpers.isSelectedProp
import com.fwdekker.randomness.testhelpers.matcher
import com.fwdekker.randomness.testhelpers.prop
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 com.intellij.ui.TitledSeparator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.fwdekker.randomness.array

import com.fwdekker.randomness.affix.AffixDecorator
import com.fwdekker.randomness.shouldValidateAsBundle
import com.fwdekker.randomness.stateDeepCopyTestFactory
import com.fwdekker.randomness.testhelpers.shouldValidateAsBundle
import io.kotest.core.NamedTag
import io.kotest.core.spec.style.FunSpec
import io.kotest.data.row
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.fwdekker.randomness.datetime

import com.fwdekker.randomness.afterNonContainer
import com.fwdekker.randomness.beforeNonContainer
import com.fwdekker.randomness.dateTimeProp
import com.fwdekker.randomness.editorApplyTestFactory
import com.fwdekker.randomness.editorFieldsTestFactory
import com.fwdekker.randomness.guiGet
import com.fwdekker.randomness.guiRun
import com.fwdekker.randomness.prop
import com.fwdekker.randomness.textProp
import com.fwdekker.randomness.valueProp
import com.fwdekker.randomness.testhelpers.afterNonContainer
import com.fwdekker.randomness.testhelpers.beforeNonContainer
import com.fwdekker.randomness.testhelpers.dateTimeProp
import com.fwdekker.randomness.testhelpers.guiGet
import com.fwdekker.randomness.testhelpers.guiRun
import com.fwdekker.randomness.testhelpers.prop
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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.fwdekker.randomness.datetime

import com.fwdekker.randomness.integer.IntegerScheme
import com.fwdekker.randomness.shouldValidateAsBundle
import com.fwdekker.randomness.stateDeepCopyTestFactory
import com.fwdekker.randomness.testhelpers.shouldValidateAsBundle
import io.kotest.assertions.withClue
import io.kotest.core.NamedTag
import io.kotest.core.spec.style.FunSpec
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.fwdekker.randomness.decimal

import com.fwdekker.randomness.afterNonContainer
import com.fwdekker.randomness.beforeNonContainer
import com.fwdekker.randomness.editorApplyTestFactory
import com.fwdekker.randomness.editorFieldsTestFactory
import com.fwdekker.randomness.guiGet
import com.fwdekker.randomness.guiRun
import com.fwdekker.randomness.isSelectedProp
import com.fwdekker.randomness.prop
import com.fwdekker.randomness.textProp
import com.fwdekker.randomness.valueProp
import com.fwdekker.randomness.testhelpers.afterNonContainer
import com.fwdekker.randomness.testhelpers.beforeNonContainer
import com.fwdekker.randomness.testhelpers.guiGet
import com.fwdekker.randomness.testhelpers.guiRun
import com.fwdekker.randomness.testhelpers.isSelectedProp
import com.fwdekker.randomness.testhelpers.prop
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.fwdekker.randomness.decimal

import com.fwdekker.randomness.affix.AffixDecorator
import com.fwdekker.randomness.array.ArrayDecorator
import com.fwdekker.randomness.shouldValidateAsBundle
import com.fwdekker.randomness.stateDeepCopyTestFactory
import com.fwdekker.randomness.testhelpers.shouldValidateAsBundle
import io.kotest.core.NamedTag
import io.kotest.core.spec.style.FunSpec
import io.kotest.data.row
Expand Down
Loading

0 comments on commit f144fce

Please sign in to comment.