Hero: instelling Hero:TitlePrefix (verborgen merkvoorvoegsel in de h1 van de tekst-only-regio)
SLP-composite: 'SLP Software: '; ASF leeg (golden files ongewijzigd). Tests en contract bijgewerkt. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -64,7 +64,48 @@ public class HeroTextOnlyTests
|
||||
HeroPictureRenderer.Render(hero, textOnlyRegion: true).IsEmpty.Should().BeTrue();
|
||||
}
|
||||
|
||||
private const string Page = "<head><!--CMS:HERO-PRELOAD--><!--/CMS:HERO-PRELOAD--></head><body><!--CMS:HERO-HTML-->baked<!--/CMS:HERO-HTML--></body>";
|
||||
[Fact]
|
||||
public void ThePrefix_IsTheFirstHiddenPartOfTheH1_AndIsEncoded()
|
||||
{
|
||||
var injection = HeroPictureRenderer.Render(TextOnly("Titel", "Label", null), textOnlyRegion: true, titlePrefix: "SLP & Co: ");
|
||||
|
||||
injection.Region.Should().Be("<h1 class=\"cms-hero-title\"><span class=\"cms-hero-title-prefix\">SLP & Co: </span><span class=\"cms-hero-tagline\">Label</span> <span class=\"cms-hero-title-lines\">Titel</span></h1>");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
public void AnEmptyPrefix_ChangesNothing(string prefix)
|
||||
{
|
||||
var hero = TextOnly();
|
||||
|
||||
HeroPictureRenderer.Render(hero, textOnlyRegion: true, titlePrefix: prefix).Region
|
||||
.Should().Be(HeroPictureRenderer.Render(hero, textOnlyRegion: true).Region).And.NotContain("title-prefix");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void APictureHero_NeverGetsThePrefix()
|
||||
{
|
||||
var variant = new HeroVariantDto("wide", 640, 427, "image/webp", "/media/hero/0123456789abcdef/wide-640.webp");
|
||||
var image = new PublicImageDto(1600, 1067, new FocusDto(0.5, 0.5, 1), "/media/hero/0123456789abcdef/wide-640.webp", [variant]);
|
||||
var hero = new PublicHeroDto("single", "Titel", null, null, [], [new PublicSlideDto("alt", "", false, image)]);
|
||||
|
||||
HeroPictureRenderer.Render(hero, textOnlyRegion: true, titlePrefix: "SLP: ").Region.Should().NotContain("title-prefix");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TheTransform_PassesTheConfiguredPrefix()
|
||||
{
|
||||
var model = Substitute.For<IHeroPageModel>();
|
||||
model.GetAsync(default).ReturnsForAnyArgs(TextOnly());
|
||||
var transform = new HeroHtmlTransform(model, Options.Create(new HeroOptions { TextOnlyRegion = true, TitlePrefix = "SLP Software: " }));
|
||||
|
||||
var html = await transform.ApplyAsync(Page, new HtmlTransformContext("https://x"), default);
|
||||
|
||||
html.Should().Contain("<h1 class=\"cms-hero-title\"><span class=\"cms-hero-title-prefix\">SLP Software: </span><span class=\"cms-hero-title-lines\">");
|
||||
}
|
||||
|
||||
private const string Page ="<head><!--CMS:HERO-PRELOAD--><!--/CMS:HERO-PRELOAD--></head><body><!--CMS:HERO-HTML-->baked<!--/CMS:HERO-HTML--></body>";
|
||||
|
||||
private static HeroHtmlTransform Transform(bool textOnly)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user