diff --git a/src/MyWebLog.Domain/SupportTypes.fs b/src/MyWebLog.Domain/SupportTypes.fs index 3d78e61..1266fd7 100644 --- a/src/MyWebLog.Domain/SupportTypes.fs +++ b/src/MyWebLog.Domain/SupportTypes.fs @@ -554,7 +554,27 @@ type PodcastOptions = { /// The medium (what the podcast IS, not what it is ABOUT) Medium: PodcastMedium option -} +} with + + /// A default set of podcast options + static member Empty = { + Title = "" + Subtitle = None + ItemsInFeed = 0 + Summary = "" + DisplayedAuthor = "" + Email = "" + ImageUrl = Permalink.Empty + AppleCategory = "" + AppleSubcategory = None + Explicit = No + DefaultMediaType = None + MediaBaseUrl = None + PodcastGuid = None + FundingUrl = None + FundingText = None + Medium = None + } /// A custom feed diff --git a/src/MyWebLog.Domain/ViewModels.fs b/src/MyWebLog.Domain/ViewModels.fs index 3b8a761..3bbdea0 100644 --- a/src/MyWebLog.Domain/ViewModels.fs +++ b/src/MyWebLog.Domain/ViewModels.fs @@ -89,7 +89,12 @@ type DisplayCustomFeed = { static member FromFeed (cats: DisplayCategory array) (feed: CustomFeed) = let source = match feed.Source with - | Category (CategoryId catId) -> $"Category: {(cats |> Array.find (fun cat -> cat.Id = catId)).Name}" + | Category (CategoryId catId) -> + cats + |> Array.tryFind (fun cat -> cat.Id = catId) + |> Option.map _.Name + |> Option.defaultValue "--INVALID; DELETE THIS FEED--" + |> sprintf "Category: %s" | Tag tag -> $"Tag: {tag}" { Id = string feed.Id Source = source diff --git a/src/MyWebLog.Tests/Domain.fs b/src/MyWebLog.Tests/Domain.fs index 09c6374..78ffeb2 100644 --- a/src/MyWebLog.Tests/Domain.fs +++ b/src/MyWebLog.Tests/Domain.fs @@ -501,6 +501,75 @@ let webLogUserTests = ] ] +// --- VIEW MODELS --- + +open MyWebLog.ViewModels + +/// Unit tests for the addBaseToRelativeUrls helper function +let addBaseToRelativeUrlsTests = + testList "PublicHelpers.addBaseToRelativeUrls" [ + test "succeeds when there is no extra URL path" { + let testText = """Howdy>""" + let modified = addBaseToRelativeUrls "" testText + Expect.equal modified testText "The text should not have been modified" + } + test "succeeds with an extra URL path" { + let testText = + """