use of com.vaadin.flow.dom.TestNodeVisitor in project flow by vaadin.
the class JavaScriptBootstrapHandlerTest method should_attachViewTo_Body_when_serverRouting.
@Test
public void should_attachViewTo_Body_when_serverRouting() throws Exception {
VaadinRequest request = mocks.createRequest(mocks, "/", "v-r=init&location=bar%3Fpar1%26par2&serverSideRouting");
jsInitHandler.handleRequest(session, request, response);
JavaScriptBootstrapUI ui = (JavaScriptBootstrapUI) UI.getCurrent();
TestNodeVisitor visitor = new TestNodeVisitor(true);
BasicElementStateProvider.get().visit(ui.getElement().getNode(), visitor);
Assert.assertTrue(hasNodeTag(visitor, "^<body>.*", ElementType.REGULAR));
Assert.assertTrue(hasNodeTag(visitor, "^<div>.*", ElementType.REGULAR));
Assert.assertTrue(hasNodeTag(visitor, "^<div>.*Could not navigate to 'bar'.*", ElementType.REGULAR));
Mockito.verify(session, Mockito.times(1)).setAttribute(SERVER_ROUTING, Boolean.TRUE);
}
use of com.vaadin.flow.dom.TestNodeVisitor 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