diff --git a/DiscordChatExporter.Cli.Tests/Specs/HtmlAttachmentSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/HtmlAttachmentSpecs.cs index 42f7acd..619c699 100644 --- a/DiscordChatExporter.Cli.Tests/Specs/HtmlAttachmentSpecs.cs +++ b/DiscordChatExporter.Cli.Tests/Specs/HtmlAttachmentSpecs.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using System.Threading.Tasks; using AngleSharp.Dom; using DiscordChatExporter.Cli.Tests.Infra; @@ -27,7 +28,11 @@ public class HtmlAttachmentSpecs .Select(e => e.GetAttribute("href")) .Should() .Contain( - "https://cdn.discordapp.com/attachments/885587741654536192/885587844964417596/Test.txt" + u => + u.StartsWith( + "https://cdn.discordapp.com/attachments/885587741654536192/885587844964417596/Test.txt", + StringComparison.Ordinal + ) ); } @@ -48,7 +53,11 @@ public class HtmlAttachmentSpecs .Select(e => e.GetAttribute("src")) .Should() .Contain( - "https://cdn.discordapp.com/attachments/885587741654536192/885654862430359613/bird-thumbnail.png" + u => + u.StartsWith( + "https://cdn.discordapp.com/attachments/885587741654536192/885654862430359613/bird-thumbnail.png", + StringComparison.Ordinal + ) ); } @@ -69,7 +78,7 @@ public class HtmlAttachmentSpecs var videoUrl = message.QuerySelector("video source")?.GetAttribute("src"); videoUrl .Should() - .Be( + .StartWith( "https://cdn.discordapp.com/attachments/885587741654536192/885655761512968233/file_example_MP4_640_3MG.mp4" ); } @@ -91,7 +100,7 @@ public class HtmlAttachmentSpecs var audioUrl = message.QuerySelector("audio source")?.GetAttribute("src"); audioUrl .Should() - .Be( + .StartWith( "https://cdn.discordapp.com/attachments/885587741654536192/885656175348187146/file_example_MP3_1MG.mp3" ); } diff --git a/DiscordChatExporter.Cli.Tests/Specs/HtmlEmbedSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/HtmlEmbedSpecs.cs index 4c155ff..3cf6331 100644 --- a/DiscordChatExporter.Cli.Tests/Specs/HtmlEmbedSpecs.cs +++ b/DiscordChatExporter.Cli.Tests/Specs/HtmlEmbedSpecs.cs @@ -145,7 +145,7 @@ public class HtmlEmbedSpecs // Assert var iframeUrl = message.QuerySelector("iframe")?.GetAttribute("src"); - iframeUrl.Should().Be("https://open.spotify.com/embed/track/1LHZMWefF9502NPfArRfvP"); + iframeUrl.Should().StartWith("https://open.spotify.com/embed/track/1LHZMWefF9502NPfArRfvP"); } [Fact] @@ -161,7 +161,7 @@ public class HtmlEmbedSpecs // Assert var iframeUrl = message.QuerySelector("iframe")?.GetAttribute("src"); - iframeUrl.Should().Be("https://www.youtube.com/embed/qOWW4OlgbvE"); + iframeUrl.Should().StartWith("https://www.youtube.com/embed/qOWW4OlgbvE"); } [Fact] diff --git a/DiscordChatExporter.Cli.Tests/Specs/HtmlStickerSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/HtmlStickerSpecs.cs index 23b5b63..44d7932 100644 --- a/DiscordChatExporter.Cli.Tests/Specs/HtmlStickerSpecs.cs +++ b/DiscordChatExporter.Cli.Tests/Specs/HtmlStickerSpecs.cs @@ -19,7 +19,7 @@ public class HtmlStickerSpecs // Assert var stickerUrl = message.QuerySelector("[title='rock'] img")?.GetAttribute("src"); - stickerUrl.Should().Be("https://cdn.discordapp.com/stickers/904215665597120572.png"); + stickerUrl.Should().StartWith("https://cdn.discordapp.com/stickers/904215665597120572.png"); } [Fact] @@ -35,6 +35,9 @@ public class HtmlStickerSpecs var stickerUrl = message .QuerySelector("[title='Yikes'] [data-source]") ?.GetAttribute("data-source"); - stickerUrl.Should().Be("https://cdn.discordapp.com/stickers/816087132447178774.json"); + + stickerUrl + .Should() + .StartWith("https://cdn.discordapp.com/stickers/816087132447178774.json"); } } diff --git a/DiscordChatExporter.Cli.Tests/Specs/JsonAttachmentSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/JsonAttachmentSpecs.cs index 26bc78d..20539eb 100644 --- a/DiscordChatExporter.Cli.Tests/Specs/JsonAttachmentSpecs.cs +++ b/DiscordChatExporter.Cli.Tests/Specs/JsonAttachmentSpecs.cs @@ -28,9 +28,10 @@ public class JsonAttachmentSpecs .GetProperty("url") .GetString() .Should() - .Be( + .StartWith( "https://cdn.discordapp.com/attachments/885587741654536192/885587844964417596/Test.txt" ); + attachments[0].GetProperty("fileName").GetString().Should().Be("Test.txt"); attachments[0].GetProperty("fileSizeBytes").GetInt64().Should().Be(11); } @@ -54,9 +55,10 @@ public class JsonAttachmentSpecs .GetProperty("url") .GetString() .Should() - .Be( + .StartWith( "https://cdn.discordapp.com/attachments/885587741654536192/885654862430359613/bird-thumbnail.png" ); + attachments[0].GetProperty("fileName").GetString().Should().Be("bird-thumbnail.png"); attachments[0].GetProperty("fileSizeBytes").GetInt64().Should().Be(466335); } @@ -80,14 +82,16 @@ public class JsonAttachmentSpecs .GetProperty("url") .GetString() .Should() - .Be( + .StartWith( "https://cdn.discordapp.com/attachments/885587741654536192/885655761512968233/file_example_MP4_640_3MG.mp4" ); + attachments[0] .GetProperty("fileName") .GetString() .Should() .Be("file_example_MP4_640_3MG.mp4"); + attachments[0].GetProperty("fileSizeBytes").GetInt64().Should().Be(3114374); } @@ -110,9 +114,10 @@ public class JsonAttachmentSpecs .GetProperty("url") .GetString() .Should() - .Be( + .StartWith( "https://cdn.discordapp.com/attachments/885587741654536192/885656175348187146/file_example_MP3_1MG.mp3" ); + attachments[0].GetProperty("fileName").GetString().Should().Be("file_example_MP3_1MG.mp3"); attachments[0].GetProperty("fileSizeBytes").GetInt64().Should().Be(1087849); } diff --git a/DiscordChatExporter.Cli.Tests/Specs/JsonStickerSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/JsonStickerSpecs.cs index f46cf84..d8d8120 100644 --- a/DiscordChatExporter.Cli.Tests/Specs/JsonStickerSpecs.cs +++ b/DiscordChatExporter.Cli.Tests/Specs/JsonStickerSpecs.cs @@ -28,7 +28,7 @@ public class JsonStickerSpecs .GetProperty("sourceUrl") .GetString() .Should() - .Be("https://cdn.discordapp.com/stickers/904215665597120572.png"); + .StartWith("https://cdn.discordapp.com/stickers/904215665597120572.png"); } [Fact] @@ -50,6 +50,6 @@ public class JsonStickerSpecs .GetProperty("sourceUrl") .GetString() .Should() - .Be("https://cdn.discordapp.com/stickers/816087132447178774.json"); + .StartWith("https://cdn.discordapp.com/stickers/816087132447178774.json"); } }