Skip to content

Commit d58883a

Browse files
committed
More test event properties settable.
1 parent c9ec973 commit d58883a

File tree

2 files changed

+57
-47
lines changed

2 files changed

+57
-47
lines changed

doc/CHANGELOG-0.10.md

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ To upgrade:
5757
##### `ext-scalaz` module
5858
* Add `Monad[CallbackOption]`.
5959

60+
##### `test` module
61+
* More test event properties settable.
62+
6063
---
6164

6265
# 0.10.1 ([commit log](https://github.com/japgolly/scalajs-react/compare/v0.10.0...v0.10.1))

test/src/main/scala/japgolly/scalajs/react/test/ReactTestUtils.scala

+54-47
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,11 @@ trait Simulate extends Object {
129129
// NOTE: Do not use UndefOr for arguments below; undefined causes Phantom-bloody-JS to crash.
130130
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
131131

132-
case class ChangeEventData(value: String = "") {
132+
case class ChangeEventData(value : String = "",
133+
defaultPrevented: Boolean = false) {
133134
def toJs: Object = {
134135
val t = Dynamic.literal()
136+
t.updateDynamic("defaultPrevented")(defaultPrevented)
135137
t.updateDynamic("value")(value)
136138
val o = Dynamic.literal("target" -> t)
137139
o
@@ -140,30 +142,32 @@ case class ChangeEventData(value: String = "") {
140142
def simulation = Simulation.change(this)
141143
}
142144

143-
case class KeyboardEventData(key: String = "",
144-
location: Double = 0,
145-
altKey: Boolean = false,
146-
ctrlKey: Boolean = false,
147-
metaKey: Boolean = false,
148-
shiftKey: Boolean = false,
149-
repeat: Boolean = false,
150-
locale: String = "",
151-
keyCode: Int = 0,
152-
charCode: Int = 0,
153-
which: Int = 0) {
145+
case class KeyboardEventData(key : String = "",
146+
location : Double = 0,
147+
altKey : Boolean = false,
148+
ctrlKey : Boolean = false,
149+
metaKey : Boolean = false,
150+
shiftKey : Boolean = false,
151+
repeat : Boolean = false,
152+
locale : String = "",
153+
keyCode : Int = 0,
154+
charCode : Int = 0,
155+
which : Int = 0,
156+
defaultPrevented: Boolean = false) {
154157
def toJs: Object = {
155158
val o = Dynamic.literal()
156-
o.updateDynamic("key" )(key )
157-
o.updateDynamic("location")(location)
158-
o.updateDynamic("altKey" )(altKey )
159-
o.updateDynamic("ctrlKey" )(ctrlKey )
160-
o.updateDynamic("metaKey" )(metaKey )
161-
o.updateDynamic("shiftKey")(shiftKey)
162-
o.updateDynamic("repeat" )(repeat )
163-
o.updateDynamic("locale" )(locale )
164-
o.updateDynamic("keyCode" )(keyCode )
165-
o.updateDynamic("charCode")(charCode)
166-
o.updateDynamic("which" )(which )
159+
o.updateDynamic("key" )(key )
160+
o.updateDynamic("location" )(location )
161+
o.updateDynamic("altKey" )(altKey )
162+
o.updateDynamic("ctrlKey" )(ctrlKey )
163+
o.updateDynamic("metaKey" )(metaKey )
164+
o.updateDynamic("shiftKey" )(shiftKey )
165+
o.updateDynamic("repeat" )(repeat )
166+
o.updateDynamic("locale" )(locale )
167+
o.updateDynamic("keyCode" )(keyCode )
168+
o.updateDynamic("charCode" )(charCode )
169+
o.updateDynamic("which" )(which )
170+
o.updateDynamic("defaultPrevented")(defaultPrevented)
167171
o
168172
}
169173
def simulateKeyDown (t: ReactOrDomNode): Unit = ReactTestUtils.Simulate.keyDown (t, this)
@@ -178,32 +182,34 @@ case class KeyboardEventData(key: String = "",
178182
def simulationKeyDownPressUp = simulationKeyDown >> simulationKeyPress >> simulationKeyUp
179183
}
180184

181-
case class MouseEventData(screenX: Double = 0,
182-
screenY: Double = 0,
183-
clientX: Double = 0,
184-
clientY: Double = 0,
185-
pageX : Double = 0,
186-
pageY : Double = 0,
187-
altKey: Boolean = false,
188-
ctrlKey: Boolean = false,
189-
metaKey: Boolean = false,
190-
shiftKey: Boolean = false,
191-
button: Int = 0,
192-
buttons: Int = 0) {
185+
case class MouseEventData(screenX : Double = 0,
186+
screenY : Double = 0,
187+
clientX : Double = 0,
188+
clientY : Double = 0,
189+
pageX : Double = 0,
190+
pageY : Double = 0,
191+
altKey : Boolean = false,
192+
ctrlKey : Boolean = false,
193+
metaKey : Boolean = false,
194+
shiftKey : Boolean = false,
195+
button : Int = 0,
196+
buttons : Int = 0,
197+
defaultPrevented: Boolean = false) {
193198
def toJs: Object = {
194199
val o = Dynamic.literal()
195-
o.updateDynamic("screenX" )(screenX )
196-
o.updateDynamic("screenY" )(screenY )
197-
o.updateDynamic("clientX" )(clientX )
198-
o.updateDynamic("clientY" )(clientY )
199-
o.updateDynamic("pageX" )(pageX )
200-
o.updateDynamic("pageY" )(pageY )
201-
o.updateDynamic("altKey" )(altKey )
202-
o.updateDynamic("ctrlKey" )(ctrlKey )
203-
o.updateDynamic("metaKey" )(metaKey )
204-
o.updateDynamic("shiftKey")(shiftKey)
205-
o.updateDynamic("button" )(button )
206-
o.updateDynamic("buttons" )(buttons )
200+
o.updateDynamic("screenX" )(screenX )
201+
o.updateDynamic("screenY" )(screenY )
202+
o.updateDynamic("clientX" )(clientX )
203+
o.updateDynamic("clientY" )(clientY )
204+
o.updateDynamic("pageX" )(pageX )
205+
o.updateDynamic("pageY" )(pageY )
206+
o.updateDynamic("altKey" )(altKey )
207+
o.updateDynamic("ctrlKey" )(ctrlKey )
208+
o.updateDynamic("metaKey" )(metaKey )
209+
o.updateDynamic("shiftKey" )(shiftKey )
210+
o.updateDynamic("button" )(button )
211+
o.updateDynamic("buttons" )(buttons )
212+
o.updateDynamic("defaultPrevented")(defaultPrevented)
207213
o
208214
}
209215
def simulateDrag (t: ReactOrDomNode) = ReactTestUtils.Simulate.drag (t, this)
@@ -213,6 +219,7 @@ case class MouseEventData(screenX: Double = 0,
213219
def simulateDragLeave (t: ReactOrDomNode) = ReactTestUtils.Simulate.dragLeave (t, this)
214220
def simulateDragOver (t: ReactOrDomNode) = ReactTestUtils.Simulate.dragOver (t, this)
215221
def simulateDragStart (t: ReactOrDomNode) = ReactTestUtils.Simulate.dragStart (t, this)
222+
def simulateDrop (t: ReactOrDomNode) = ReactTestUtils.Simulate.drop (t, this)
216223
def simulateMouseDown (t: ReactOrDomNode) = ReactTestUtils.Simulate.mouseDown (t, this)
217224
def simulateMouseEnter(t: ReactOrDomNode) = ReactTestUtils.Simulate.mouseEnter(t, this)
218225
def simulateMouseLeave(t: ReactOrDomNode) = ReactTestUtils.Simulate.mouseLeave(t, this)

0 commit comments

Comments
 (0)