use of org.sonar.plugins.html.node.Node in project sonar-web by SonarSource.
the class PageLexerTest method testDirectiveNode.
@Test
public void testDirectiveNode() {
String directive = "<!docTyPE html " + "PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
DoctypeTokenizer tokenizer = new DoctypeTokenizer("<!DOCTYPE", ">");
List<Node> nodeList = new ArrayList<>();
CodeReader codeReader = new CodeReader(directive);
tokenizer.consume(codeReader, nodeList);
assertThat(nodeList).hasSize(1);
Node node = nodeList.get(0);
assertThat(node).isInstanceOf(DirectiveNode.class);
assertThat(((DirectiveNode) node).getAttributes()).hasSize(4);
}
use of org.sonar.plugins.html.node.Node in project sonar-web by SonarSource.
the class PageLexerTest method attribute_value_starting_with_quote.
@Test
public void attribute_value_starting_with_quote() {
StringReader reader = new StringReader("<img src=\"'a'\"/>");
List<Node> nodeList = new PageLexer().parse(reader);
assertThat(nodeList).hasSize(1);
assertThat(nodeList.get(0)).isInstanceOf(TagNode.class);
TagNode node = (TagNode) nodeList.get(0);
Attribute attribute = node.getAttributes().get(0);
assertThat(attribute.getName()).isEqualTo("src");
assertThat(attribute.getValue()).isEqualTo("'a'");
}
use of org.sonar.plugins.html.node.Node in project sonar-web by SonarSource.
the class VueLexerTest method testMalformedTemplate2.
@Test
public void testMalformedTemplate2() {
String fragment = "<foo/><bar/></template>";
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 testVoidTemplate.
@Test
public void testVoidTemplate() {
String fragment = "<template></template>";
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 testNestedTemplates.
@Test
public void testNestedTemplates() {
String fragment = "<template><template><template><template></template></template></template></template>";
StringReader reader = new StringReader(fragment);
VueLexer lexer = new VueLexer();
List<Node> nodeList = lexer.parse(reader);
assertThat(nodeList).hasSize(6);
}
Aggregations