use of org.sonar.plugins.html.node.Node in project sonar-web by SonarSource.
the class PageLexerTest method testNestedComment.
@Test
public void testNestedComment() {
String fragment = "<!-- text <!--><p>This is not part of the comment</p>";
StringReader reader = new StringReader(fragment);
PageLexer lexer = new PageLexer();
List<Node> nodeList = lexer.parse(reader);
assertThat(nodeList).hasSize(4);
assertThat(nodeList.get(0)).isInstanceOf(CommentNode.class);
assertThat(nodeList.get(1)).isInstanceOf(TagNode.class);
assertThat(nodeList.get(2)).isInstanceOf(TextNode.class);
assertThat(nodeList.get(3)).isInstanceOf(TagNode.class);
}
use of org.sonar.plugins.html.node.Node in project sonar-web by SonarSource.
the class PageLexerTest method testNestedTagInAttribute.
@Test
public void testNestedTagInAttribute() {
String fragment = "<td id=\"typeCellHeader\"<c:if test='${param.typeNormalOrError == \"error\"}'>" + "style=\"display:none;\"</c:if>>Type" + "</td>";
StringReader reader = new StringReader(fragment);
PageLexer lexer = new PageLexer();
List<Node> nodeList = lexer.parse(reader);
assertThat(nodeList).hasSize(3);
assertThat(nodeList.get(0)).isInstanceOf(TagNode.class);
assertThat(nodeList.get(1)).isInstanceOfAny(TextNode.class);
assertThat(nodeList.get(2)).isInstanceOf(TagNode.class);
TagNode tagNode = (TagNode) nodeList.get(0);
assertThat(tagNode.getAttributes()).hasSize(4);
// the embedded tags are added as attributes
assertThat(tagNode.getAttributes().get(1).getValue()).isEmpty();
assertThat(tagNode.getAttributes().get(3).getValue()).isEmpty();
}
use of org.sonar.plugins.html.node.Node in project sonar-web by SonarSource.
the class VueLexerTest method testMissingTemplate.
@Test
public void testMissingTemplate() {
String fragment = "";
StringReader reader = new StringReader(fragment);
VueLexer lexer = new VueLexer();
List<Node> nodeList = lexer.parse(reader);
assertThat(nodeList).isEmpty();
}
use of org.sonar.plugins.html.node.Node in project sonar-web by SonarSource.
the class VueLexerTest method testMalformedTemplate1.
@Test
public void testMalformedTemplate1() {
String fragment = "<template><foo/><bar/>";
StringReader reader = new StringReader(fragment);
VueLexer lexer = new VueLexer();
List<Node> nodeList = lexer.parse(reader);
assertThat(nodeList).hasSize(2);
}
use of org.sonar.plugins.html.node.Node in project sonar-web by SonarSource.
the class VueLexerTest method testEmptyTemplate.
@Test
public void testEmptyTemplate() {
String fragment = "<template/>";
StringReader reader = new StringReader(fragment);
VueLexer lexer = new VueLexer();
List<Node> nodeList = lexer.parse(reader);
assertThat(nodeList).isEmpty();
}
Aggregations