|
| 1 | +using System; |
| 2 | +using Xunit; |
| 3 | + |
| 4 | +namespace PreMailer.Net.Tests |
| 5 | +{ |
| 6 | + public class Base64UrlTests |
| 7 | + { |
| 8 | + [Fact] |
| 9 | + public void MoveCssInline_WithUnquotedBase64BackgroundImage_ShouldPreserveBase64Data() |
| 10 | + { |
| 11 | + string input = "<style>.pt-logo { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA); background-repeat: no-repeat; }</style><span class=\"pt-logo\"></span>"; |
| 12 | + |
| 13 | + var result = PreMailer.MoveCssInline(input); |
| 14 | + |
| 15 | + Assert.Contains("background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA)", result.Html); |
| 16 | + Assert.Contains("background-repeat: no-repeat", result.Html); |
| 17 | + } |
| 18 | + |
| 19 | + [Fact] |
| 20 | + public void MoveCssInline_WithQuotedBase64BackgroundImage_ShouldPreserveBase64Data() |
| 21 | + { |
| 22 | + string input = "<style>.pt-logo { background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA\"); background-repeat: no-repeat; }</style><span class=\"pt-logo\"></span>"; |
| 23 | + |
| 24 | + var result = PreMailer.MoveCssInline(input); |
| 25 | + |
| 26 | + Assert.Contains("background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA\")", result.Html); |
| 27 | + Assert.Contains("background-repeat: no-repeat", result.Html); |
| 28 | + } |
| 29 | + |
| 30 | + [Fact] |
| 31 | + public void MoveCssInline_WithSvgXmlBackgroundImage_ShouldPreserveEncodedData() |
| 32 | + { |
| 33 | + string input = "<style>.my-icon { background-image: url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' width='8' height='8' viewBox='0 0 8 8'%3e%3cpath d='M5.25 0l-4 4 4 4 1.5-1.5L4.25 4l2.5-2.5L5.25 0z'/%3e%3c/svg%3e\"); }</style><span class=\"my-icon\"></span>"; |
| 34 | + |
| 35 | + var result = PreMailer.MoveCssInline(input); |
| 36 | + |
| 37 | + Assert.Contains("background-image: url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' width='8' height='8' viewBox='0 0 8 8'%3e%3cpath d='M5.25 0l-4 4 4 4 1.5-1.5L4.25 4l2.5-2.5L5.25 0z'/%3e%3c/svg%3e\")", result.Html); |
| 38 | + } |
| 39 | + |
| 40 | + [Fact] |
| 41 | + public void MoveCssInline_WithBase64DataWithDoubleEquals_ShouldPreserveEnding() |
| 42 | + { |
| 43 | + string input = "<style>.pt-logo { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA==); }</style><span class=\"pt-logo\"></span>"; |
| 44 | + |
| 45 | + var result = PreMailer.MoveCssInline(input); |
| 46 | + |
| 47 | + Assert.Contains("background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA==)", result.Html); |
| 48 | + } |
| 49 | + } |
| 50 | +} |
0 commit comments