Search in sources :

Example 6 with LitTemplateParser

use of com.vaadin.flow.component.littemplate.LitTemplateParser in project flow by vaadin.

the class LitTemplateParserImplTest method severalJsModuleAnnotations_theFirstFileDoesNotExist_fileWithContentIsChosen.

@Test
public void severalJsModuleAnnotations_theFirstFileDoesNotExist_fileWithContentIsChosen() {
    LitTemplateParser instance = LitTemplateParserImpl.getInstance();
    LitTemplateParser.TemplateData templateContent = instance.getTemplateContent(BrokenJsModuleAnnotation.class, "my-lit-element-view", service);
    Assert.assertEquals("Parent element ID not the expected one.", "my-lit-element-view", templateContent.getTemplateElement().parent().id());
}
Also used : TemplateData(com.vaadin.flow.component.littemplate.LitTemplateParser.TemplateData) LitTemplateParser(com.vaadin.flow.component.littemplate.LitTemplateParser) Test(org.junit.Test)

Example 7 with LitTemplateParser

use of com.vaadin.flow.component.littemplate.LitTemplateParser in project flow by vaadin.

the class LitTemplateParserImplTest method getTemplateContent_sourceNotFoundInStatsFile_returnsNull.

@Test
public void getTemplateContent_sourceNotFoundInStatsFile_returnsNull() {
    LitTemplateParser instance = LitTemplateParserImpl.getInstance();
    Assert.assertNull(instance.getTemplateContent(FooView.class, "foo-view", service));
}
Also used : LitTemplateParser(com.vaadin.flow.component.littemplate.LitTemplateParser) Test(org.junit.Test)

Example 8 with LitTemplateParser

use of com.vaadin.flow.component.littemplate.LitTemplateParser in project flow by vaadin.

the class LitTemplateParserImplTest method getTypescriptTemplateContent_templateExists_getTemplateContent.

@Test
public void getTypescriptTemplateContent_templateExists_getTemplateContent() {
    LitTemplateParser instance = LitTemplateParserImpl.getInstance();
    TemplateData templateContent = instance.getTemplateContent(MyForm.class, "my-form", service);
    Assert.assertEquals("Parent element ID not the expected one.", "my-form", templateContent.getTemplateElement().parent().id());
    Assert.assertEquals("Expected template element to have 2 children", 2, templateContent.getTemplateElement().childNodeSize());
    Assert.assertEquals("Template element should have contained a div element with the id 'label'", "vaadin-text-field", templateContent.getTemplateElement().getElementById("nameField").tag().toString());
}
Also used : TemplateData(com.vaadin.flow.component.littemplate.LitTemplateParser.TemplateData) LitTemplateParser(com.vaadin.flow.component.littemplate.LitTemplateParser) Test(org.junit.Test)

Aggregations

LitTemplateParser (com.vaadin.flow.component.littemplate.LitTemplateParser)8 Test (org.junit.Test)8 TemplateData (com.vaadin.flow.component.littemplate.LitTemplateParser.TemplateData)6