slate-simulator
A simulator to help writing tests for Slate editors and plugins. By default the simulator does not include the core plugins as they have a lot of dependencies on browser-specific globals, so running them in CI environments is very hard. If you need the core plugins for your use case you need to import them manually.
Example
Example with core plugins
Core plugins will trigger default behaviour for the events. Without them, only the changes defined in the plugins passed to slate-simulator will be applied. For example, beforeInput()
event will not insert the data's text if none of the plugins being tested does it.
Example for DataTransfer
events
DataTransfer
eventsIn order to simulate paste and drop events you will need to create a DataTransfer. However this object is browser dependant and is not easy to manipulate in CI environments. The easiest work around is to fake its API with a mockup class:
Later, you can use it this way to fake a paste event:
Methods
beforeInput
beforeInput
beforeInput(event: Object) => Simulator
Simulator a beforeinput
event with an event
object.
blur
blur
blur(event: Object) => Simulator
Simulator a blur
event with an event
object.
copy
copy
copy(event: Object) => Simulator
Simulator a copy
event with an event
object.
cut
cut
cut(event: Object) => Simulator
Simulator a cut
event with an event
object.
drop
drop
drop(event: Object) => Simulator
Simulator a drop
event with an event
object.
focus
focus
focus(event: Object) => Simulator
Simulator a focus
event with an event
object.
keyDown
keyDown
keyDown(event: Object) => Simulator
Simulator a keyDown
event with an event
object.
keyUp
keyUp
keyUp(event: Object) => Simulator
Simulator a keyUp
event with an event
object.
paste
paste
paste(event: Object) => Simulator
Simulator a paste
event with an event
object.
select
select
select(event: Object) => Simulator
Simulator a select
event with an event
object.
Last updated