use of com.googlecode.jslint4java.JSLintResult in project jslint4java by happygiraffe.
the class ReportFormatterTest method testOutput.
@Test
public void testOutput() throws Exception {
// Normally, JSLint produces non-xml reports (though they are HTML). But as we control the
// input we can get away with using xmlunit to make the check for us. We still have to
// accommodate the extra div that we insert.
JSLintResult result = mockResult("foo.js");
String expected = "<div class='file'>" + "<h1 id='foo.js'>foo.js</h1>" + "<div>undefined cat: schrodinger</div>" + "</div>";
XMLUnit.compareXML(expected, form.format(result));
}
use of com.googlecode.jslint4java.JSLintResult in project jslint4java by happygiraffe.
the class ReportFormatterTest method testEscaping.
@Test
public void testEscaping() throws Exception {
JSLintResult result = mockResult("'a<b&c>d\".js");
String expected = "<h1 id=''a<b&c>d".js'>'a<b&c>d\".js</h1>";
assertThat(form.format(result).contains(expected), is(true));
}
use of com.googlecode.jslint4java.JSLintResult in project jslint4java by happygiraffe.
the class JUnitXmlFormatterTest method testEscaping.
@Test
public void testEscaping() throws Exception {
String expected = "<testsuite failures=\"1\" time=\"0.000\" errors=\"1\" skipped=\"0\" " + "tests=\"1\" name=\""a&b'.js\">" + "<testcase time=\"0.000\" classname=\"com.googlecode.jslint4java\" " + "name=\""a&b'.js\">" + "<failure message=\"Found 1 problem\" type=\"java.lang.AssertionError\">" + "\"a&b'.js:1:1:I<&>Like<angle>>\"brackets'\n" + "</failure>" + "</testcase>" + "</testsuite>";
String name = "\"a&b\'.js";
Issue issue = new Issue.IssueBuilder(name, 1, 1, "I<&>Like<angle>>\"brackets\'").build();
JSLintResult result = new JSLintResult.ResultBuilder(name).duration(0).addIssue(issue).build();
XMLAssert.assertXMLEqual(expected, form.format(result));
}
use of com.googlecode.jslint4java.JSLintResult in project jslint4java by happygiraffe.
the class JUnitXmlFormatterTest method testOneProblem.
@Test
public void testOneProblem() throws Exception {
String expected = "<testsuite failures=\"1\" time=\"0.000\" errors=\"1\" skipped=\"0\" " + "tests=\"1\" name=\"hello.js\">" + "<testcase time=\"0.000\" classname=\"com.googlecode.jslint4java\" name=\"hello.js\">" + "<failure message=\"Found 1 problem\" type=\"java.lang.AssertionError\">" + "hello.js:1:1:too many aardvarks\n" + "</failure>" + "</testcase>" + "</testsuite>";
String name = "hello.js";
Issue issue = new Issue.IssueBuilder(name, 1, 1, "too many aardvarks").build();
JSLintResult result = new JSLintResult.ResultBuilder(name).duration(0).addIssue(issue).build();
XMLAssert.assertXMLEqual(expected, form.format(result));
}
use of com.googlecode.jslint4java.JSLintResult in project jslint4java by happygiraffe.
the class PlainFormatterTest method shouldCopeWithCharacterZero.
/** We don't expect this to happen, but we shouldn't blow up either. @see issue 85 */
@Test
public void shouldCopeWithCharacterZero() throws Exception {
String nl = System.getProperty("line.separator");
String name = "foo/bar.js";
Issue issue = new IssueBuilder(name, 0, 0, "oops").evidence("BANG").build();
JSLintResult result = new JSLintResult.ResultBuilder(name).addIssue(issue).build();
StringBuilder sb = new StringBuilder(name);
sb.append(":0:0: oops").append(nl);
sb.append("BANG").append(nl);
sb.append("^").append(nl);
assertThat(rf.format(result), is(sb.toString()));
}
Aggregations