コード例 #1
0
        public void CanValidateScriptWithSingleQuote()
        {
            // Arrange
            var validator = new JsHintValidator();

            // Act
            var result = validator.Validate("$('.test');", new Options());

            // Assert
            Assert.That(result, Is.Not.Null);
        }
コード例 #2
0
        public void CanValidateValidScript()
        {
            // Arrange
            var script = "var answer = 42;";
            var validator = new JsHintValidator();

            // Act
            var result = validator.Validate(script, new Options());

            // Assert
            Assert.That(result.Errors.Count, Is.EqualTo(0));
        }
コード例 #3
0
        public void CanValidateScriptWithOctalEscapeSequence()
        {
            // Arrange
            var script = "var x = \"\\012\";";
            var validator = new JsHintValidator();

            // Act
            var result = validator.Validate(script, new Options());

            // Assert
            Assert.That(result, Is.Not.Null);
        }
コード例 #4
0
        public void CanFindErrorInScript()
        {
            // Arrange
            var script = "var answer = 42 == 42;";
            var validator = new JsHintValidator();

            // Act
            var result = validator.Validate(script, new Options {Eqeqeq = true});

            // Assert
            Assert.That(result.Errors.Count, Is.EqualTo(1));
        }
コード例 #5
0
        public void CanValidateScriptWithNewLine()
        {
            // Arrange
            var validator = new JsHintValidator();

            // Act
            var result = validator.Validate(@"
                $(document).ready(function () {
                });
            ", new Options());

            // Assert
            Assert.That(result, Is.Not.Null);
        }