-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated readme + module rename
- Loading branch information
Showing
12 changed files
with
267 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using FluentAssertions; | ||
using Statiq.Testing; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Kontent.Statiq.Tests | ||
{ | ||
public class When_processing_images : BaseFixture | ||
{ | ||
[Fact] | ||
public async Task It_should_extract_asset_urls() | ||
{ | ||
// Given | ||
const string url = "https://the.cms/assets/image1.jpg"; | ||
string content = $"<img src='{url}'/>"; | ||
|
||
var document = new TestDocument(content); | ||
|
||
// When | ||
var assetParser = new KontentImageProcessor(); | ||
var output = await ExecuteAsync(new[]{document}, assetParser); | ||
|
||
// Then | ||
output.Length.Should().Be(1); | ||
var outputDoc = output[0]; | ||
|
||
var urls = outputDoc.GetKontentImageDownloads(); | ||
|
||
urls.Should().Contain( dl => dl.OriginalUrl == url ); | ||
} | ||
|
||
[Theory, | ||
InlineData("https://the.cms/images/image1.jpg", "/assets/img/image1.jpg"), | ||
InlineData("https://the.cms/images/image1.jpg?w=110&h=340", "/assets/img/2cddd89b6d47fa06efe3e14ceada65c7-image1.jpg"), | ||
InlineData("https://the.cms/images/image1.jpg?h=340&w=110", "/assets/img/2cddd89b6d47fa06efe3e14ceada65c7-image1.jpg")] | ||
public async Task It_should_replace_url_with_local_path(string sourceUrl, string localUrl) | ||
{ | ||
// Given | ||
string content = $"<img src='{sourceUrl}'/>"; | ||
|
||
var document = new TestDocument(content); | ||
|
||
// When | ||
var assetParser = new KontentImageProcessor().WithLocalPath("/assets/img"); | ||
var output = await ExecuteAsync(new[] { document }, assetParser); | ||
|
||
// Then | ||
output.Length.Should().Be(1); | ||
var outputDoc = output[0]; | ||
|
||
outputDoc.Content.Should().Contain($"src=\"{localUrl}\""); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.