use of com.vaadin.flow.component.ComponentTest.TestComponent in project flow by vaadin.
the class ComponentEventBusTest method multipleEventsForSameDomEvent_fireEvent.
@Test
public void multipleEventsForSameDomEvent_fireEvent() {
TestComponent component = new TestComponent();
EventTracker<MappedToDomEvent> eventTracker = new EventTracker<>();
EventTracker<MappedToDomNoDataEvent> eventTracker2 = new EventTracker<>();
component.addListener(MappedToDomEvent.class, eventTracker);
component.addListener(MappedToDomNoDataEvent.class, eventTracker2);
JsonObject eventData = createData("event.someData", 42, "event.moreData", 19);
fireDomEvent(component, "dom-event", eventData);
eventTracker.assertEventCalled(component, true);
Assert.assertEquals("19", eventTracker.getEvent().getMoreData());
Assert.assertEquals(42, eventTracker.getEvent().getSomeData());
Assert.assertEquals(component, eventTracker.getEvent().getSource());
eventTracker2.assertEventCalled(component, true);
}
use of com.vaadin.flow.component.ComponentTest.TestComponent in project flow by vaadin.
the class ComponentEventBusTest method serverNoDataEvent_fire.
@Test
public void serverNoDataEvent_fire() {
TestComponent c = new TestComponent();
EventTracker<ServerNoDataEvent> eventTracker = new EventTracker<>();
c.addListener(ServerNoDataEvent.class, eventTracker);
c.fireEvent(new ServerNoDataEvent(c, false));
eventTracker.assertEventCalled(c, false);
Assert.assertFalse(eventTracker.getEvent().isFromClient());
}
use of com.vaadin.flow.component.ComponentTest.TestComponent in project flow by vaadin.
the class ComponentEventBusTest method domEvent_fireClientEvent.
@Test
public void domEvent_fireClientEvent() {
TestComponent component = new TestComponent();
EventTracker<MappedToDomEvent> eventTracker = new EventTracker<>();
component.addListener(MappedToDomEvent.class, eventTracker);
JsonObject eventData = createData("event.someData", 42, "event.moreData", 1);
fireDomEvent(component, "dom-event", eventData);
eventTracker.assertEventCalled(component, true);
MappedToDomEvent event = eventTracker.getEvent();
Assert.assertEquals(42, event.getSomeData());
Assert.assertEquals("1", event.getMoreData());
}
use of com.vaadin.flow.component.ComponentTest.TestComponent in project flow by vaadin.
the class ComponentEventBusTest method nonDomEvent_fireEvent.
@Test
public void nonDomEvent_fireEvent() {
TestComponent component = new TestComponent();
EventTracker<ServerEvent> eventTracker = new EventTracker<>();
component.addListener(ServerEvent.class, eventTracker);
component.fireEvent(new ServerEvent(component, new BigDecimal("12.2")));
eventTracker.assertEventCalled(component, false);
}
use of com.vaadin.flow.component.ComponentTest.TestComponent in project flow by vaadin.
the class ComponentEventBusTest method mappedDomEvent_fire_noListeners.
@Test
public void mappedDomEvent_fire_noListeners() {
TestComponent c = new TestComponent();
fireDomEvent(c, "dom-event", Json.createObject());
}
Aggregations