Search in sources :

Example 16 with JSLintResult

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));
}
Also used : JSLintResult(com.googlecode.jslint4java.JSLintResult) Test(org.junit.Test)

Example 17 with JSLintResult

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='&apos;a&lt;b&amp;c&gt;d&quot;.js'>'a&lt;b&amp;c&gt;d\".js</h1>";
    assertThat(form.format(result).contains(expected), is(true));
}
Also used : JSLintResult(com.googlecode.jslint4java.JSLintResult) Test(org.junit.Test)

Example 18 with JSLintResult

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=\"&quot;a&amp;b&apos;.js\">" + "<testcase time=\"0.000\" classname=\"com.googlecode.jslint4java\" " + "name=\"&quot;a&amp;b&apos;.js\">" + "<failure message=\"Found 1 problem\" type=\"java.lang.AssertionError\">" + "\"a&amp;b'.js:1:1:I&lt;&amp;&gt;Like&lt;angle&gt;&gt;\"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));
}
Also used : Issue(com.googlecode.jslint4java.Issue) JSLintResult(com.googlecode.jslint4java.JSLintResult) Test(org.junit.Test)

Example 19 with JSLintResult

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));
}
Also used : Issue(com.googlecode.jslint4java.Issue) JSLintResult(com.googlecode.jslint4java.JSLintResult) Test(org.junit.Test)

Example 20 with JSLintResult

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()));
}
Also used : Issue(com.googlecode.jslint4java.Issue) JSLintResult(com.googlecode.jslint4java.JSLintResult) IssueBuilder(com.googlecode.jslint4java.Issue.IssueBuilder) Test(org.junit.Test)

Aggregations

JSLintResult (com.googlecode.jslint4java.JSLintResult)20 Test (org.junit.Test)17 Issue (com.googlecode.jslint4java.Issue)9 IssueBuilder (com.googlecode.jslint4java.Issue.IssueBuilder)3 BufferedReader (java.io.BufferedReader)2 JSLint (com.googlecode.jslint4java.JSLint)1 UnicodeBomInputStream (com.googlecode.jslint4java.UnicodeBomInputStream)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStreamReader (java.io.InputStreamReader)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1