@Test public void testDefault() { SourceFile file = JavaScriptAstScanner.scanSingleFile( new File("src/test/resources/checks/tooManyLinesInFile.js"), check); CheckMessagesVerifier.verify(file.getCheckMessages()).noMore(); }
@Test public void test() { SourceFile file = JavaScriptAstScanner.scanSingleFile( new File("src/test/resources/checks/parsingError.js"), new ParsingErrorCheck()); CheckMessagesVerifier.verify(file.getCheckMessages()) .next() .atLine(3) .withMessageThat(containsString("Parse error")) .noMore(); }
@Test public void testCustom() { check.maximum = 1; SourceFile file = JavaScriptAstScanner.scanSingleFile( new File("src/test/resources/checks/tooManyLinesInFile.js"), check); CheckMessagesVerifier.verify(file.getCheckMessages()) .next() .withMessage( "File \"tooManyLinesInFile.js\" has 7 lines, which is greater than 1 authorized. Split it into smaller files.") .noMore(); }
@Test public void test() { ElseIfWithoutElseCheck check = new ElseIfWithoutElseCheck(); SourceFile file = JavaScriptAstScanner.scanSingleFile( new File("src/test/resources/checks/elseIfWithoutElse.js"), check); CheckMessagesVerifier.verify(file.getCheckMessages()) .next() .atLine(15) .withMessage("End this if...else if construct by an else clause.") .noMore(); }
@Test public void test() { LineLengthCheck check = new LineLengthCheck(); check.maximumLineLength = 30; SourceFile file = JavaScriptAstScanner.scanSingleFile( new File("src/test/resources/checks/lineLength.js"), check); CheckMessagesVerifier.verify(file.getCheckMessages()) .next() .atLine(2) .withMessage("The line contains 44 characters which is greater than 30 authorized.") .noMore(); }
@Test public void test() { ParenthesesCheck check = new ParenthesesCheck(); SourceFile file = JavaScriptAstScanner.scanSingleFile( new File("src/test/resources/checks/parentheses.js"), check); CheckMessagesVerifier.verify(file.getCheckMessages()) .next() .atLine(2) .next() .atLine(8) .next() .atLine(12) .next() .atLine(15) .next() .atLine(23) .next() .atLine(26) .next() .atLine(30) .noMore(); }