Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
More tests:
  • Loading branch information
DamianEdwards committed Feb 25, 2015
1 parent eae4b42 commit 519fd27
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/Microsoft.AspNet.Mvc.TagHelpers.Test/ScriptTagHelperTest.cs
Expand Up @@ -361,6 +361,42 @@ public async Task PreservesOrderOfSourceAttributesWhenRun()
Assert.Empty(logger.Logged);
}

[Fact]
public async Task RendersScriptTagsForGlobbedSrcResults()
{
// Arrange
var context = MakeTagHelperContext(
attributes: new Dictionary<string, object>
{
["src"] = "/js/site.js",
["asp-src-include"] = "**/*.js"
});
var output = MakeTagHelperOutput("script", attributes: new Dictionary<string, string>
{
["src"] = "/js/site.js"
});
var logger = new Mock<ILogger<ScriptTagHelper>>();
var hostingEnvironment = MakeHostingEnvironment();
var viewContext = MakeViewContext();
var globbingUrlBuilder = new Mock<GlobbingUrlBuilder>();
globbingUrlBuilder.Setup(g => g.BuildUrlList("/js/site.js", "**/*.js", null))
.Returns(new[] { "/js/site.js", "/common.js" });
var helper = new ScriptTagHelper
{
GlobbingUrlBuilder = globbingUrlBuilder.Object,
Logger = logger.Object,
HostingEnvironment = hostingEnvironment,
ViewContext = viewContext,
SrcInclude = "**/*.js"
};

// Act
await helper.ProcessAsync(context, output);

// Assert
Assert.Equal("<script src=\"/js/site.js\"></script><script src=\"/common.js\"></script>", output.Content);
}

private TagHelperContext MakeTagHelperContext(
IDictionary<string, object> attributes = null,
string content = null)
Expand Down

0 comments on commit 519fd27

Please sign in to comment.