use of com.vaadin.flow.component.internal.JavaScriptBootstrapUI in project flow by vaadin.
the class UidlRequestHandlerTest method should_changeURL_when_v7LocationProvided.
@Test
public void should_changeURL_when_v7LocationProvided() throws Exception {
JavaScriptBootstrapUI ui = mock(JavaScriptBootstrapUI.class);
UidlRequestHandler handler = spy(new UidlRequestHandler());
StringWriter writer = new StringWriter();
JsonObject uidl = generateUidl(true, true);
doReturn(uidl).when(handler).createUidl(ui, false);
handler.writeUidl(ui, writer, false);
String out = writer.toString();
uidl = JsonUtil.parse(out.substring(9, out.length() - 1));
assertEquals("setTimeout(() => history.pushState(null, null, 'http://localhost:9998/#!away'));", uidl.getArray("execute").getArray(1).getString(1));
}
use of com.vaadin.flow.component.internal.JavaScriptBootstrapUI in project flow by vaadin.
the class UidlRequestHandlerTest method should_not_modify_non_MPR_Uidl.
@Test
public void should_not_modify_non_MPR_Uidl() throws Exception {
JavaScriptBootstrapUI ui = mock(JavaScriptBootstrapUI.class);
UidlRequestHandler handler = spy(new UidlRequestHandler());
StringWriter writer = new StringWriter();
JsonObject uidl = generateUidl(true, true);
uidl.getArray("execute").getArray(2).remove(1);
doReturn(uidl).when(handler).createUidl(ui, false);
handler.writeUidl(ui, writer, false);
String expected = uidl.toJson();
String out = writer.toString();
uidl = JsonUtil.parse(out.substring(9, out.length() - 1));
String actual = uidl.toJson();
assertEquals(expected, actual);
}
use of com.vaadin.flow.component.internal.JavaScriptBootstrapUI in project flow by vaadin.
the class JavaScriptBootstrapHandlerTest method should_attachViewTo_UiContainer.
@Test
public void should_attachViewTo_UiContainer() throws Exception {
VaadinRequest request = mocks.createRequest(mocks, "/", "v-r=init&foo&location=");
jsInitHandler.handleRequest(session, request, response);
JavaScriptBootstrapUI ui = (JavaScriptBootstrapUI) UI.getCurrent();
ui.connectClient("a-tag", "an-id", "a-route", "", null);
TestNodeVisitor visitor = new TestNodeVisitor(true);
BasicElementStateProvider.get().visit(ui.getElement().getNode(), visitor);
Assert.assertTrue(hasNodeTag(visitor, "^<body>.*", ElementType.REGULAR));
Assert.assertTrue(hasNodeTag(visitor, "^<a-tag>.*", ElementType.VIRTUAL_ATTACHED));
Assert.assertTrue(hasNodeTag(visitor, "^<div>.*", ElementType.REGULAR));
Assert.assertTrue(hasNodeTag(visitor, "^<div>.*Could not navigate to 'a-route'.*", ElementType.REGULAR));
}
Aggregations