Move OpenGraph property generation to models (#52)
- Add auto-OpenGraph field to web log - Only generate properties for posts/pages without them if this flag is set - Set flag to yes on v3 database migration - Add JSON converter for OpenGraph type - Add tests for models
This commit is contained in:
@@ -257,6 +257,346 @@ let markupTextTests = testList "MarkupText" [
|
||||
]
|
||||
]
|
||||
|
||||
/// Unit tests for the OpenGraphAudio type
|
||||
let openGraphAudioTests = testList "OpenGraphAudio" [
|
||||
testList "Properties" [
|
||||
test "succeeds with minimum required" {
|
||||
let props = Array.ofSeq { OpenGraphAudio.Empty with Url = "http://test.this" }.Properties
|
||||
Expect.hasLength props 1 "There should be one property"
|
||||
Expect.equal props[0] ("og:audio", "http://test.this") "The URL was not written correctly"
|
||||
}
|
||||
test "succeeds with secure URL" {
|
||||
let props = Array.ofSeq { OpenGraphAudio.Empty with Url = "https://test.this" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[0] ("og:audio", "https://test.this") "The URL was not written correctly"
|
||||
Expect.equal
|
||||
props[1] ("og:audio:secure_url", "https://test.this") "The Secure URL was not written correctly"
|
||||
}
|
||||
test "succeeds with all properties filled" {
|
||||
let props =
|
||||
{ Url = "http://test.this"
|
||||
SecureUrl = Some "https://test.other"
|
||||
Type = Some "audio/mpeg" }.Properties
|
||||
|> Array.ofSeq
|
||||
Expect.hasLength props 3 "There should be three properties"
|
||||
Expect.equal props[0] ("og:audio", "http://test.this") "The URL was not written correctly"
|
||||
Expect.equal
|
||||
props[1] ("og:audio:secure_url", "https://test.other") "The Secure URL was not written correctly"
|
||||
Expect.equal props[2] ("og:audio:type", "audio/mpeg") "The MIME type was not written correctly"
|
||||
}
|
||||
test "succeeds when deriving AAC" {
|
||||
let props = Array.ofSeq { OpenGraphAudio.Empty with Url = "/this/cool.file.aac" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[1] ("og:audio:type", "audio/aac") "The MIME type for AAC was not derived correctly"
|
||||
}
|
||||
test "succeeds when deriving MP3" {
|
||||
let props = Array.ofSeq { OpenGraphAudio.Empty with Url = "/an.other/song.mp3" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[1] ("og:audio:type", "audio/mpeg") "The MIME type for MP3 was not derived correctly"
|
||||
}
|
||||
test "succeeds when deriving OGA" {
|
||||
let props = Array.ofSeq { OpenGraphAudio.Empty with Url = "/talks/speex.oga" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[1] ("og:audio:type", "audio/ogg") "The MIME type for OGA was not derived correctly"
|
||||
}
|
||||
test "succeeds when deriving WAV" {
|
||||
let props = Array.ofSeq { OpenGraphAudio.Empty with Url = "/some/old.school.wav" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[1] ("og:audio:type", "audio/wav") "The MIME type for WAV was not derived correctly"
|
||||
}
|
||||
test "succeeds when deriving WEBA" {
|
||||
let props = Array.ofSeq { OpenGraphAudio.Empty with Url = "/new/format/file.weba" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[1] ("og:audio:type", "audio/webm") "The MIME type for WEBA was not derived correctly"
|
||||
}
|
||||
test "succeeds when type cannot be derived" {
|
||||
let props = Array.ofSeq { OpenGraphAudio.Empty with Url = "/profile.jpg" }.Properties
|
||||
Expect.hasLength props 1 "There should be one property (only URL; no type derived)"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
/// Tests for the OpenGraphImage type
|
||||
let openGraphImageTests = testList "OpenGraphImage" [
|
||||
testList "Properties" [
|
||||
test "succeeds with minimum required" {
|
||||
let props = Array.ofSeq { OpenGraphImage.Empty with Url = "http://test.url" }.Properties
|
||||
Expect.hasLength props 1 "There should be one property"
|
||||
Expect.equal props[0] ("og:image", "http://test.url") "The URL was not written correctly"
|
||||
}
|
||||
test "succeeds with secure URL" {
|
||||
let props = Array.ofSeq { OpenGraphImage.Empty with Url = "https://secure.url" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[0] ("og:image", "https://secure.url") "The URL was not written correctly"
|
||||
Expect.equal
|
||||
props[1] ("og:image:secure_url", "https://secure.url") "The Secure URL was not written correctly"
|
||||
}
|
||||
test "succeeds with all properties filled" {
|
||||
let props =
|
||||
{ Url = "http://test.this"
|
||||
SecureUrl = Some "https://test.other"
|
||||
Type = Some "image/jpeg"
|
||||
Width = Some 400
|
||||
Height = Some 600
|
||||
Alt = Some "This ought to be good" }.Properties
|
||||
|> Array.ofSeq
|
||||
Expect.hasLength props 6 "There should be six properties"
|
||||
Expect.equal props[0] ("og:image", "http://test.this") "The URL was not written correctly"
|
||||
Expect.equal
|
||||
props[1] ("og:image:secure_url", "https://test.other") "The Secure URL was not written correctly"
|
||||
Expect.equal props[2] ("og:image:type", "image/jpeg") "The MIME type was not written correctly"
|
||||
Expect.equal props[3] ("og:image:width", "400") "The width was not written correctly"
|
||||
Expect.equal props[4] ("og:image:height", "600") "The height was not written correctly"
|
||||
Expect.equal props[5] ("og:image:alt", "This ought to be good") "The alt text was not written correctly"
|
||||
}
|
||||
test "succeeds when deriving BMP" {
|
||||
let props = Array.ofSeq { OpenGraphImage.Empty with Url = "/old/windows.bmp" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[1] ("og:image:type", "image/bmp") "The MIME type for BMP was not derived correctly"
|
||||
}
|
||||
test "succeeds when deriving GIF" {
|
||||
let props = Array.ofSeq { OpenGraphImage.Empty with Url = "/its.a.soft.g.gif" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[1] ("og:image:type", "image/gif") "The MIME type for GIF was not derived correctly"
|
||||
}
|
||||
test "succeeds when deriving ICO" {
|
||||
let props = Array.ofSeq { OpenGraphImage.Empty with Url = "/favicon.ico" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal
|
||||
props[1] ("og:image:type", "image/vnd.microsoft.icon") "The MIME type for ICO was not derived correctly"
|
||||
}
|
||||
test "succeeds when deriving JPEG" {
|
||||
let props = Array.ofSeq { OpenGraphImage.Empty with Url = "/big/name/photo.jpeg" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[1] ("og:image:type", "image/jpeg") "The MIME type for JPEG was not derived correctly"
|
||||
}
|
||||
test "succeeds when deriving PNG" {
|
||||
let props = Array.ofSeq { OpenGraphImage.Empty with Url = "/some/nice/graphic.png" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[1] ("og:image:type", "image/png") "The MIME type for PNG was not derived correctly"
|
||||
}
|
||||
test "succeeds when deriving SVG" {
|
||||
let props = Array.ofSeq { OpenGraphImage.Empty with Url = "/fancy-new-vector.svg" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[1] ("og:image:type", "image/svg+xml") "The MIME type for SVG was not derived correctly"
|
||||
}
|
||||
test "succeeds when deriving TIF" {
|
||||
let props = Array.ofSeq { OpenGraphImage.Empty with Url = "/tagged/file.tif" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[1] ("og:image:type", "image/tiff") "The MIME type for TIF was not derived correctly"
|
||||
}
|
||||
test "succeeds when deriving TIFF" {
|
||||
let props = Array.ofSeq { OpenGraphImage.Empty with Url = "/tagged/file.two.tiff" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[1] ("og:image:type", "image/tiff") "The MIME type for TIFF was not derived correctly"
|
||||
}
|
||||
test "succeeds when deriving WEBP" {
|
||||
let props = Array.ofSeq { OpenGraphImage.Empty with Url = "/modern/photo.webp" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[1] ("og:image:type", "image/webp") "The MIME type for WEBP was not derived correctly"
|
||||
}
|
||||
test "succeeds when type cannot be derived" {
|
||||
let props = Array.ofSeq { OpenGraphImage.Empty with Url = "/intro.mp3" }.Properties
|
||||
Expect.hasLength props 1 "There should be one property (only URL; no type derived)"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
/// Unit tests for the OpenGraphVideo type
|
||||
let openGraphVideoTests = testList "OpenGraphVideo" [
|
||||
testList "Properties" [
|
||||
test "succeeds with minimum required" {
|
||||
let props = Array.ofSeq { OpenGraphVideo.Empty with Url = "http://url.test" }.Properties
|
||||
Expect.hasLength props 1 "There should be one property"
|
||||
Expect.equal props[0] ("og:video", "http://url.test") "The URL was not written correctly"
|
||||
}
|
||||
test "succeeds with secure URL" {
|
||||
let props = Array.ofSeq { OpenGraphVideo.Empty with Url = "https://url.secure" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[0] ("og:video", "https://url.secure") "The URL was not written correctly"
|
||||
Expect.equal
|
||||
props[1] ("og:video:secure_url", "https://url.secure") "The Secure URL was not written correctly"
|
||||
}
|
||||
test "succeeds with all properties filled" {
|
||||
let props =
|
||||
{ Url = "http://test.this"
|
||||
SecureUrl = Some "https://test.other"
|
||||
Type = Some "video/mpeg"
|
||||
Width = Some 1200
|
||||
Height = Some 900 }.Properties
|
||||
|> Array.ofSeq
|
||||
Expect.hasLength props 5 "There should be five properties"
|
||||
Expect.equal props[0] ("og:video", "http://test.this") "The URL was not written correctly"
|
||||
Expect.equal
|
||||
props[1] ("og:video:secure_url", "https://test.other") "The Secure URL was not written correctly"
|
||||
Expect.equal props[2] ("og:video:type", "video/mpeg") "The MIME type was not written correctly"
|
||||
Expect.equal props[3] ("og:video:width", "1200") "The width was not written correctly"
|
||||
Expect.equal props[4] ("og:video:height", "900") "The height was not written correctly"
|
||||
}
|
||||
test "succeeds when deriving AVI" {
|
||||
let props = Array.ofSeq { OpenGraphVideo.Empty with Url = "/my.video.avi" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[1] ("og:video:type", "video/x-msvideo") "The MIME type for AVI was not derived correctly"
|
||||
}
|
||||
test "succeeds when deriving MP4" {
|
||||
let props = Array.ofSeq { OpenGraphVideo.Empty with Url = "/chapters/1/01.mp4" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[1] ("og:video:type", "video/mp4") "The MIME type for MP4 was not derived correctly"
|
||||
}
|
||||
test "succeeds when deriving MPEG" {
|
||||
let props = Array.ofSeq { OpenGraphVideo.Empty with Url = "/viral/video.mpeg" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[1] ("og:video:type", "video/mpeg") "The MIME type for MPEG was not derived correctly"
|
||||
}
|
||||
test "succeeds when deriving OGV" {
|
||||
let props = Array.ofSeq { OpenGraphVideo.Empty with Url = "/open/video/example.ogv" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[1] ("og:video:type", "video/ogg") "The MIME type for OGV was not derived correctly"
|
||||
}
|
||||
test "succeeds when deriving WEBM" {
|
||||
let props = Array.ofSeq { OpenGraphVideo.Empty with Url = "/images/hero.webm" }.Properties
|
||||
Expect.hasLength props 2 "There should be two properties"
|
||||
Expect.equal props[1] ("og:video:type", "video/webm") "The MIME type for WEBM was not derived correctly"
|
||||
}
|
||||
test "succeeds when type cannot be derived" {
|
||||
let props = Array.ofSeq { OpenGraphVideo.Empty with Url = "/favicon.ico" }.Properties
|
||||
Expect.hasLength props 1 "There should be one property (only URL; no type derived)"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
/// Unit tests for the OpenGraphType type
|
||||
let openGraphTypeTests = testList "OpenGraphType" [
|
||||
testList "Parse" [
|
||||
test "succeeds for \"article\"" {
|
||||
Expect.equal (OpenGraphType.Parse "article") Article "\"article\" not parsed correctly"
|
||||
}
|
||||
test "succeeds for \"book\"" {
|
||||
Expect.equal (OpenGraphType.Parse "book") Book "\"book\" not parsed correctly"
|
||||
}
|
||||
test "succeeds for \"music.album\"" {
|
||||
Expect.equal (OpenGraphType.Parse "music.album") MusicAlbum "\"music.album\" not parsed correctly"
|
||||
}
|
||||
test "succeeds for \"music.playlist\"" {
|
||||
Expect.equal (OpenGraphType.Parse "music.playlist") MusicPlaylist "\"music.playlist\" not parsed correctly"
|
||||
}
|
||||
test "succeeds for \"music.radio_station\"" {
|
||||
Expect.equal
|
||||
(OpenGraphType.Parse "music.radio_station")
|
||||
MusicRadioStation
|
||||
"\"music.radio_station\" not parsed correctly"
|
||||
}
|
||||
test "succeeds for \"music.song\"" {
|
||||
Expect.equal (OpenGraphType.Parse "music.song") MusicSong "\"music.song\" not parsed correctly"
|
||||
}
|
||||
test "succeeds for \"payment.link\"" {
|
||||
Expect.equal (OpenGraphType.Parse "payment.link") PaymentLink "\"payment.link\" not parsed correctly"
|
||||
}
|
||||
test "succeeds for \"profile\"" {
|
||||
Expect.equal (OpenGraphType.Parse "profile") Profile "\"profile\" not parsed correctly"
|
||||
}
|
||||
test "succeeds for \"video.episode\"" {
|
||||
Expect.equal (OpenGraphType.Parse "video.episode") VideoEpisode "\"video.episode\" not parsed correctly"
|
||||
}
|
||||
test "succeeds for \"video.movie\"" {
|
||||
Expect.equal (OpenGraphType.Parse "video.movie") VideoMovie "\"video.movie\" not parsed correctly"
|
||||
}
|
||||
test "succeeds for \"video.other\"" {
|
||||
Expect.equal (OpenGraphType.Parse "video.other") VideoOther "\"video.other\" not parsed correctly"
|
||||
}
|
||||
test "succeeds for \"video.tv_show\"" {
|
||||
Expect.equal (OpenGraphType.Parse "video.tv_show") VideoTvShow "\"video.tv_show\" not parsed correctly"
|
||||
}
|
||||
test "succeeds for \"website\"" {
|
||||
Expect.equal (OpenGraphType.Parse "website") Website "\"website\" not parsed correctly"
|
||||
}
|
||||
test "fails for invalid type" {
|
||||
Expect.throwsT<ArgumentException>
|
||||
(fun () -> ignore (OpenGraphType.Parse "anthology")) "Invalid value should have raised an exception"
|
||||
}
|
||||
]
|
||||
testList "ToString" [
|
||||
test "succeeds for Article" {
|
||||
Expect.equal (string Article) "article" "Article string incorrect"
|
||||
}
|
||||
test "succeeds for Book" {
|
||||
Expect.equal (string Book) "book" "Book string incorrect"
|
||||
}
|
||||
test "succeeds for MusicAlbum" {
|
||||
Expect.equal (string MusicAlbum) "music.album" "MusicAlbum string incorrect"
|
||||
}
|
||||
test "succeeds for MusicPlaylist" {
|
||||
Expect.equal (string MusicPlaylist) "music.playlist" "MusicPlaylist string incorrect"
|
||||
}
|
||||
test "succeeds for MusicRadioStation" {
|
||||
Expect.equal (string MusicRadioStation) "music.radio_station" "MusicRadioStation string incorrect"
|
||||
}
|
||||
test "succeeds for MusicSong" {
|
||||
Expect.equal (string MusicSong) "music.song" "MusicSong string incorrect"
|
||||
}
|
||||
test "succeeds for PaymentLink" {
|
||||
Expect.equal (string PaymentLink) "payment.link" "PaymentLink string incorrect"
|
||||
}
|
||||
test "succeeds for Profile" {
|
||||
Expect.equal (string Profile) "profile" "Profile string incorrect"
|
||||
}
|
||||
test "succeeds for VideoEpisode" {
|
||||
Expect.equal (string VideoEpisode) "video.episode" "VideoEpisode string incorrect"
|
||||
}
|
||||
test "succeeds for VideoMovie" {
|
||||
Expect.equal (string VideoMovie) "video.movie" "VideoMovie string incorrect"
|
||||
}
|
||||
test "succeeds for VideoOther" {
|
||||
Expect.equal (string VideoOther) "video.other" "VideoOther string incorrect"
|
||||
}
|
||||
test "succeeds for VideoTvShow" {
|
||||
Expect.equal (string VideoTvShow) "video.tv_show" "VideoTvShow string incorrect"
|
||||
}
|
||||
test "succeeds for Website" {
|
||||
Expect.equal (string Website) "website" "Website string incorrect"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
/// Unit tests for the OpenGraphProperties type
|
||||
let openGraphPropertiesTests = testList "OpenGraphProperties" [
|
||||
testList "Properties" [
|
||||
test "succeeds with minimal values" {
|
||||
let props =
|
||||
{ OpenGraphProperties.Empty with
|
||||
Image = { OpenGraphImage.Empty with Url = "http://this.aint.nothing" } }.Properties
|
||||
|> Array.ofSeq
|
||||
Expect.hasLength props 2 "There should have been two properties"
|
||||
Expect.equal props[0] ("og:type", "article") "Type not written correctly"
|
||||
Expect.equal props[1] ("og:image", "http://this.aint.nothing") "Image URL not written correctly"
|
||||
}
|
||||
test "succeeds with all values" {
|
||||
let props =
|
||||
{ Type = Book
|
||||
Image = { OpenGraphImage.Empty with Url = "http://this.image.file" }
|
||||
Audio = Some { OpenGraphAudio.Empty with Url = "http://this.audio.file" }
|
||||
Description = Some "This is a unit test"
|
||||
Determiner = Some "a"
|
||||
Locale = Some "en_US"
|
||||
LocaleAlternate = Some [ "en_UK"; "es_MX" ]
|
||||
Video = Some { OpenGraphVideo.Empty with Url = "http://this.video.file" }
|
||||
Other = Some [ { Name = "book.publisher"; Value = "Yep" } ] }.Properties
|
||||
|> Array.ofSeq
|
||||
Expect.hasLength props 10 "There should have been ten properties"
|
||||
Expect.equal props[0] ("og:type", "book") "Type not written correctly"
|
||||
Expect.equal props[1] ("og:image", "http://this.image.file") "Image URL not written correctly"
|
||||
Expect.equal props[2] ("og:description", "This is a unit test") "Description not written correctly"
|
||||
Expect.equal props[3] ("og:determiner", "a") "Determiner not written correctly"
|
||||
Expect.equal props[4] ("og:locale", "en_US") "Locale not written correctly"
|
||||
Expect.equal props[5] ("og:locale:alternate", "en_UK") "1st Alternate Locale not written correctly"
|
||||
Expect.equal props[6] ("og:locale:alternate", "es_MX") "2nd Alternate Locale not written correctly"
|
||||
Expect.equal props[7] ("og:audio", "http://this.audio.file") "Audio URL not written correctly"
|
||||
Expect.equal props[8] ("og:video", "http://this.video.file") "Video URL not written correctly"
|
||||
Expect.equal props[9] ("book.publisher", "Yep") "Other property not written correctly"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
/// Unit tests for the PodcastMedium type
|
||||
let podcastMediumTests = testList "PodcastMedium" [
|
||||
testList "Parse" [
|
||||
@@ -407,6 +747,11 @@ let all = testList "SupportTypes" [
|
||||
explicitRatingTests
|
||||
episodeTests
|
||||
markupTextTests
|
||||
openGraphAudioTests
|
||||
openGraphImageTests
|
||||
openGraphVideoTests
|
||||
openGraphTypeTests
|
||||
openGraphPropertiesTests
|
||||
podcastMediumTests
|
||||
postStatusTests
|
||||
customFeedSourceTests
|
||||
|
||||
@@ -233,7 +233,7 @@ let testFullPost =
|
||||
ImageUrl = Some "uploads/podcast-cover.jpg"
|
||||
Subtitle = Some "Narration"
|
||||
Explicit = Some Clean
|
||||
Chapters = None
|
||||
Chapters = None
|
||||
ChapterFile = Some "uploads/1970/01/chapters.txt"
|
||||
ChapterType = Some "chapters"
|
||||
ChapterWaypoints = Some true
|
||||
@@ -666,7 +666,7 @@ let editPostModelTests = testList "EditPostModel" [
|
||||
{ testFullPost.Episode.Value with
|
||||
Chapters = Some []
|
||||
ChapterFile = None
|
||||
ChapterType = None } }
|
||||
ChapterType = None } }
|
||||
Expect.equal model.ChapterSource "internal" "ChapterSource not filled properly"
|
||||
}
|
||||
]
|
||||
@@ -677,7 +677,7 @@ let editPostModelTests = testList "EditPostModel" [
|
||||
model.Source <- "HTML"
|
||||
model.Text <- "<p>An updated post!</p>"
|
||||
model.Tags <- "Zebras, Aardvarks, , Turkeys"
|
||||
model.Template <- "updated"
|
||||
model.Template <- "updated"
|
||||
model.CategoryIds <- [| "cat-x"; "cat-y" |]
|
||||
model.MetaNames <- [| "Zed Meta"; "A Meta" |]
|
||||
model.MetaValues <- [| "A Value"; "Zed Value" |]
|
||||
@@ -688,7 +688,7 @@ let editPostModelTests = testList "EditPostModel" [
|
||||
model.ImageUrl <- "updated-cover.png"
|
||||
model.Subtitle <- "Talking"
|
||||
model.Explicit <- "no"
|
||||
model.ChapterSource <- "external"
|
||||
model.ChapterSource <- "external"
|
||||
model.ChapterFile <- "updated-chapters.txt"
|
||||
model.ChapterType <- "indexes"
|
||||
model.TranscriptUrl <- "updated-transcript.txt"
|
||||
@@ -696,7 +696,7 @@ let editPostModelTests = testList "EditPostModel" [
|
||||
model.TranscriptLang <- "ES-mx"
|
||||
model.SeasonNumber <- 4
|
||||
model.SeasonDescription <- "Season Fo"
|
||||
model.EpisodeNumber <- "432.1"
|
||||
model.EpisodeNumber <- "432.1"
|
||||
model.EpisodeDescription <- "Four Three Two pt One"
|
||||
model
|
||||
testList "UpdatePost" [
|
||||
@@ -760,7 +760,7 @@ let editPostModelTests = testList "EditPostModel" [
|
||||
minModel.SeasonNumber <- 0
|
||||
minModel.SeasonDescription <- ""
|
||||
minModel.EpisodeNumber <- ""
|
||||
minModel.EpisodeDescription <- ""
|
||||
minModel.EpisodeDescription <- ""
|
||||
let post = minModel.UpdatePost testFullPost (Noda.epoch + Duration.FromDays 500)
|
||||
Expect.isSome post.Episode "There should have been a podcast episode"
|
||||
let ep = post.Episode.Value
|
||||
@@ -785,7 +785,7 @@ let editPostModelTests = testList "EditPostModel" [
|
||||
}
|
||||
test "succeeds for a podcast episode with internal chapters" {
|
||||
let minModel = updatedModel ()
|
||||
minModel.ChapterSource <- "internal"
|
||||
minModel.ChapterSource <- "internal"
|
||||
minModel.ChapterFile <- ""
|
||||
minModel.ChapterType <- ""
|
||||
let post = minModel.UpdatePost testFullPost (Noda.epoch + Duration.FromDays 500)
|
||||
@@ -977,7 +977,7 @@ let editUserModelTests = testList "EditUserModel" [
|
||||
let model =
|
||||
{ Id = "test-user"
|
||||
AccessLevel = "WebLogAdmin"
|
||||
Email = "again@example.com"
|
||||
Email = "again@example.com"
|
||||
Url = ""
|
||||
FirstName = "Another"
|
||||
LastName = "One"
|
||||
@@ -1115,10 +1115,10 @@ let postListItemTests = testList "PostListItem" [
|
||||
{ Post.Empty with
|
||||
Id = PostId "full-post"
|
||||
AuthorId = WebLogUserId "me"
|
||||
Status = Published
|
||||
Status = Published
|
||||
Title = "Finished Product"
|
||||
Permalink = Permalink "2021/post.html"
|
||||
PublishedOn = Some (Noda.epoch + Duration.FromHours 12)
|
||||
PublishedOn = Some (Noda.epoch + Duration.FromHours 12)
|
||||
UpdatedOn = Noda.epoch + Duration.FromHours 13
|
||||
Text = """<a href="/other-post.html">Click</a>"""
|
||||
CategoryIds = [ CategoryId "z"; CategoryId "y" ]
|
||||
@@ -1157,13 +1157,14 @@ let settingsModelTests = testList "SettingsModel" [
|
||||
let model =
|
||||
SettingsModel.FromWebLog
|
||||
{ WebLog.Empty with
|
||||
Name = "The Web Log"
|
||||
Slug = "the-web-log"
|
||||
DefaultPage = "this-one"
|
||||
PostsPerPage = 18
|
||||
TimeZone = "America/Denver"
|
||||
ThemeId = ThemeId "my-theme"
|
||||
AutoHtmx = true }
|
||||
Name = "The Web Log"
|
||||
Slug = "the-web-log"
|
||||
DefaultPage = "this-one"
|
||||
PostsPerPage = 18
|
||||
TimeZone = "America/Denver"
|
||||
ThemeId = ThemeId "my-theme"
|
||||
AutoHtmx = true
|
||||
AutoOpenGraph = false }
|
||||
Expect.equal model.Name "The Web Log" "Name not filled properly"
|
||||
Expect.equal model.Slug "the-web-log" "Slug not filled properly"
|
||||
Expect.equal model.Subtitle "" "Subtitle not filled properly"
|
||||
@@ -1173,6 +1174,7 @@ let settingsModelTests = testList "SettingsModel" [
|
||||
Expect.equal model.ThemeId "my-theme" "ThemeId not filled properly"
|
||||
Expect.isTrue model.AutoHtmx "AutoHtmx should have been set"
|
||||
Expect.equal model.Uploads "Database" "Uploads not filled properly"
|
||||
Expect.isFalse model.AutoOpenGraph "AutoOpenGraph should have been unset"
|
||||
}
|
||||
test "succeeds with a subtitle" {
|
||||
let model = SettingsModel.FromWebLog { WebLog.Empty with Subtitle = Some "sub here!" }
|
||||
@@ -1182,15 +1184,16 @@ let settingsModelTests = testList "SettingsModel" [
|
||||
testList "Update" [
|
||||
test "succeeds with no subtitle" {
|
||||
let webLog =
|
||||
{ Name = "Interesting"
|
||||
Slug = "some-stuff"
|
||||
Subtitle = ""
|
||||
DefaultPage = "that-one"
|
||||
PostsPerPage = 8
|
||||
TimeZone = "America/Chicago"
|
||||
ThemeId = "test-theme"
|
||||
AutoHtmx = true
|
||||
Uploads = "Disk" }.Update WebLog.Empty
|
||||
{ Name = "Interesting"
|
||||
Slug = "some-stuff"
|
||||
Subtitle = ""
|
||||
DefaultPage = "that-one"
|
||||
PostsPerPage = 8
|
||||
TimeZone = "America/Chicago"
|
||||
ThemeId = "test-theme"
|
||||
AutoHtmx = true
|
||||
Uploads = "Disk"
|
||||
AutoOpenGraph = false }.Update WebLog.Empty
|
||||
Expect.equal webLog.Name "Interesting" "Name not filled properly"
|
||||
Expect.equal webLog.Slug "some-stuff" "Slug not filled properly"
|
||||
Expect.isNone webLog.Subtitle "Subtitle should not have had a value"
|
||||
@@ -1200,6 +1203,7 @@ let settingsModelTests = testList "SettingsModel" [
|
||||
Expect.equal webLog.ThemeId (ThemeId "test-theme") "ThemeId not filled properly"
|
||||
Expect.isTrue webLog.AutoHtmx "AutoHtmx should have been set"
|
||||
Expect.equal webLog.Uploads Disk "Uploads not filled properly"
|
||||
Expect.isFalse webLog.AutoOpenGraph "AutoOpenGraph should have been unset"
|
||||
}
|
||||
test "succeeds with a subtitle" {
|
||||
let webLog = { SettingsModel.FromWebLog WebLog.Empty with Subtitle = "Sub" }.Update WebLog.Empty
|
||||
|
||||
Reference in New Issue
Block a user