public void JsMinifyKeepsImportantCommentsTest()
        {
            string         js      = "/*!I am important */";
            JsMinifyUglify jsmin   = new JsMinifyUglify();
            BundleContext  context = new BundleContext(
                new Mock <HttpContextBase>().Object,
                new Mock <BundleCollection>().Object,
                "/test/virtualpath");
            BundleResponse response = new BundleResponse(js, null);

            response.Content = js;
            jsmin.Process(context, response);
            Assert.IsTrue(response.Content.StartsWith(js));
        }
        public void JsMinifyRemovesCommentsNewLinesAndSpacesTest()
        {
            string         js      = "//I am a comment\r\nfoo = bar;\r\nfoo = yes;";
            JsMinifyUglify jsmin   = new JsMinifyUglify();
            BundleContext  context = new BundleContext(
                new Mock <HttpContextBase>().Object,
                new Mock <BundleCollection>().Object,
                "/test/virtualpath");
            BundleResponse response = new BundleResponse(js, null);

            response.Content = js;
            jsmin.Process(context, response);
            Assert.AreEqual("foo=bar;foo=yes", response.Content);
        }
        public void JsMinifyDoesNotMinifyInInstrumentationModeTest()
        {
            string         js      = "foo = bar;\r\nfoo = yes;";
            JsMinifyUglify jsmin   = new JsMinifyUglify();
            BundleContext  context = new BundleContext(
                new Mock <HttpContextBase>().Object,
                new Mock <BundleCollection>().Object,
                "/test/virtualpath");

            context.EnableInstrumentation = true;
            BundleResponse response = new BundleResponse(js, null);

            response.Content = js;
            jsmin.Process(context, response);
            Assert.AreEqual(js, response.Content);
        }
        public void JsMinifyDoesNotRenameEvalMethods()
        {
            // Based of WebFormsUIValidation.js eval usage
            string         js      = @"function ValidatorOnLoad() {
    var i, val;
    for (i = 0; i < 10; i++) {
        val = i;
        eval(""val.evaluationfunction = "" + val.evaluationfunction + "";"");
    }
}";
            JsMinifyUglify jsmin   = new JsMinifyUglify();
            BundleContext  context = new BundleContext(
                new Mock <HttpContextBase>().Object,
                new Mock <BundleCollection>().Object,
                "/test/virtualpath");
            BundleResponse response = new BundleResponse(js, null);

            response.Content = js;
            jsmin.Process(context, response);
            Assert.IsTrue(response.Content.Contains("eval(\"val.evaluationfunction"));
        }