public void GivenRendererWithUrlGenerator_WhenRenderBundle_ThenScriptHtmlIsReturned() { var urlGenerator = new Mock<IUrlGenerator>(); var renderer = new ScriptBundleHtmlRenderer(urlGenerator.Object); var bundle = new ScriptBundle("~/test"); urlGenerator.Setup(g => g.CreateBundleUrl(bundle)) .Returns("URL"); var html = renderer.Render(bundle); html.ShouldEqual("<script src=\"URL\" type=\"text/javascript\"></script>"); }
public void GivenRendererWithUrlGeneratorWithHtmlAttributes_WhenRenderBundle_ThenScriptHtmlIsReturned() { var urlGenerator = new Mock<IUrlGenerator>(); var renderer = new ScriptBundleHtmlRenderer(urlGenerator.Object); var bundle = new ScriptBundle("~/test"); bundle.HtmlAttributes.Add( new { Async = "async", @class = "isDismissed" } ); urlGenerator.Setup(g => g.CreateBundleUrl(bundle)) .Returns("URL"); var html = renderer.Render(bundle); html.ShouldEqual("<script src=\"URL\" type=\"text/javascript\" async=\"async\" class=\"isDismissed\"></script>"); }
public void GivenScriptBundleWithNotIECondition_WhenRender_ThenHtmlConditionalCommentWrapsLinkButLeavesScriptVisibleToAllBrowsers() { var urlGenerator = new Mock<IUrlGenerator>(); var renderer = new ScriptBundleHtmlRenderer(urlGenerator.Object); var bundle = new ScriptBundle("~/test") { Condition = "(gt IE 9)| !IE" }; urlGenerator.Setup(g => g.CreateBundleUrl(bundle)) .Returns("URL"); var html = renderer.Render(bundle); html.ShouldEqual( "<!--[if " + bundle.Condition + "]><!-->" + Environment.NewLine + "<script src=\"URL\" type=\"text/javascript\"></script>" + Environment.NewLine + "<!-- <![endif]-->" ); }
public void GivenScriptBundleWithCondition_WhenRender_ThenHtmlConditionalCommentWrapsLink() { var urlGenerator = new Mock<IUrlGenerator>(); var renderer = new ScriptBundleHtmlRenderer(urlGenerator.Object); var bundle = new ScriptBundle("~/test") {Condition = "CONDITION"}; urlGenerator.Setup(g => g.CreateBundleUrl(bundle)) .Returns("URL"); var html = renderer.Render(bundle); html.ShouldEqual( "<!--[if CONDITION]>" + Environment.NewLine + "<script src=\"URL\" type=\"text/javascript\"></script>" + Environment.NewLine + "<![endif]-->" ); }