Skip to content

Commit 7a848d5

Browse files
committed
make enum more readable
1 parent c7252e0 commit 7a848d5

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

lib/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ publishing {
3636
publications {
3737
create<MavenPublication>("maven") {
3838
groupId = project.group.toString()
39-
artifactId = project.name
39+
artifactId = "selenium-testing-library"
4040
version = project.version.toString()
4141
from(components["kotlin"])
4242
artifact(tasks["sourcesJar"])

lib/src/main/kotlin/seleniumtestinglib/WebElement.kt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,19 @@ internal val WebElement.wrappedDriver get() = (this as RemoteWebElement).wrapped
142142

143143
fun WebElement.fireEvent(eventName: Event, eventProperties: Map<String, Map<String, Any?>> = emptyMap()): Any? {
144144
wrappedDriver.ensureScript("testing-library.js", "fireEvent.change")
145-
return wrappedDriver.executeScript("fireEvent.$eventName(arguments[0], arguments[1])", this, eventProperties)
145+
val event = eventName.name.replaceFirstChar(Char::lowercase)
146+
return wrappedDriver.executeScript("fireEvent.$event(arguments[0], arguments[1])", this, eventProperties)
146147
}
147148

148149
@Suppress("unused")
149150
enum class Event {
150-
copy, cut, paste, compositionEnd, compositionStart, compositionUpdate, keyDown, keyPress, keyUp, focus, blur,
151-
focusIn, focusOut, change, input, invalid, submit, reset, click, contextMenu, dblClick, drag, dragEnd, dragEnter,
152-
dragExit, dragLeave, dragOver, dragStart, drop, mouseDown, mouseEnter, mouseLeave, mouseMove, mouseOut, mouseOver,
153-
mouseUp, select, touchCancel, touchEnd, touchMove, touchStart, resize, scroll, wheel, abort, canPlay,
154-
canPlayThrough, durationChange, emptied, encrypted, ended, loadedData, loadedMetadata, loadStart, pause, play,
155-
playing, progress, rateChange, seeked, seeking, stalled, suspend, timeUpdate, volumeChange, waiting, load, error,
156-
animationStart, animationEnd, animationIteration, transitionCancel, transitionEnd, transitionRun, transitionStart,
157-
pointerOver, pointerEnter, pointerDown, pointerMove, pointerUp, pointerCancel, pointerOut, pointerLeave,
158-
gotPointerCapture, lostPointerCapture, popState, offline, online, doubleClick
151+
Copy, Cut, Paste, CompositionEnd, CompositionStart, CompositionUpdate, KeyDown, KeyPress, KeyUp, Focus, Blur,
152+
FocusIn, FocusOut, Change, Input, Invalid, Submit, Reset, Click, ContextMenu, DblClick, Drag, DragEnd, DragEnter,
153+
DragExit, DragLeave, DragOver, DragStart, Drop, MouseDown, MouseEnter, MouseLeave, MouseMove, MouseOut, MouseOver,
154+
MouseUp, Select, TouchCancel, TouchEnd, TouchMove, TouchStart, Resize, Scroll, Wheel, Abort, CanPlay,
155+
CanPlayThrough, DurationChange, Emptied, Encrypted, Ended, LoadedData, LoadedMetadata, LoadStart, Pause, Play,
156+
Playing, Progress, RateChange, Seeked, Seeking, Stalled, Suspend, TimeUpdate, VolumeChange, Waiting, Load, Error,
157+
AnimationStart, AnimationEnd, AnimationIteration, TransitionCancel, TransitionEnd, TransitionRun, TransitionStart,
158+
PointerOver, PointerEnter, PointerDown, PointerMove, PointerUp, PointerCancel, PointerOut, PointerLeave,
159+
GotPointerCapture, LostPointerCapture, PopState, Offline, Online, DoubleClick
159160
}

lib/src/test/kotlin/seleniumtestinglib/FireEventTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package seleniumtestinglib
22

33
import org.junit.jupiter.api.extension.ExtendWith
44
import org.openqa.selenium.remote.RemoteWebDriver
5-
import seleniumtestinglib.Event.change
5+
import seleniumtestinglib.Event.Change
66
import seleniumtestinglib.locators.ByRole
77
import seleniumtestinglib.locators.Role.TextBox
88
import kotlin.test.Test
@@ -16,7 +16,7 @@ class FireEventTest(private val driver: RemoteWebDriver) {
1616
driver.render("""<input />""")
1717
val input = driver.findElement(ByRole(TextBox))
1818

19-
input.fireEvent(change, mapOf("target" to mapOf("value" to "2020-05-24")))
19+
input.fireEvent(Change, mapOf("target" to mapOf("value" to "2020-05-24")))
2020

2121
assertEquals("2020-05-24", input.value)
2222
}

0 commit comments

Comments
 (0)