Implement htmax as auto-htmx selection (#59)

- Move program support items to MyWebLog namespace
- Fix parameter ordering in some tests
This commit is contained in:
2026-07-05 21:28:58 -04:00
parent 9d2277ab32
commit fcd02ecbec
12 changed files with 213 additions and 153 deletions
+41 -10
View File
@@ -31,16 +31,16 @@ let nodaTests = testList "Noda" [
let accessLevelTests = testList "AccessLevel" [
testList "Parse" [
test "succeeds for \"Author\"" {
Expect.equal Author (AccessLevel.Parse "Author") "Author not parsed correctly"
Expect.equal (AccessLevel.Parse "Author") Author "Author not parsed correctly"
}
test "succeeds for \"Editor\"" {
Expect.equal Editor (AccessLevel.Parse "Editor") "Editor not parsed correctly"
Expect.equal (AccessLevel.Parse "Editor") Editor "Editor not parsed correctly"
}
test "succeeds for \"WebLogAdmin\"" {
Expect.equal WebLogAdmin (AccessLevel.Parse "WebLogAdmin") "WebLogAdmin not parsed correctly"
Expect.equal (AccessLevel.Parse "WebLogAdmin") WebLogAdmin "WebLogAdmin not parsed correctly"
}
test "succeeds for \"Administrator\"" {
Expect.equal Administrator (AccessLevel.Parse "Administrator") "Administrator not parsed correctly"
Expect.equal (AccessLevel.Parse "Administrator") Administrator "Administrator not parsed correctly"
}
test "fails when given an unrecognized value" {
Expect.throwsT<ArgumentException>
@@ -113,17 +113,47 @@ let accessLevelTests = testList "AccessLevel" [
]
]
/// Tests for the AutoHtmxType type
let autoHtmxTypeTests = testList "AutoHtmxType" [
testList "Parse" [
test "succeeds for \"NoAutoHtmx\"" {
Expect.equal (AutoHtmxType.Parse "No") NoAutoHtmx "No not parsed correctly"
}
test "succeeds for \"AutoHtmx\"" {
Expect.equal (AutoHtmxType.Parse "Yes") AutoHtmx "Yes not parsed correctly"
}
test "succeeds for \"AutoHtmax\"" {
Expect.equal (AutoHtmxType.Parse "Max") AutoHtmax "Max not parsed correctly"
}
test "fails for unrecognized value" {
Expect.throwsT<ArgumentException>
(fun () -> ignore (AutoHtmxType.Parse "Sure")) "Invalid value should have raised an exception"
}
]
testList "ToString" [
test "NoAutoHtmx succeeds" {
Expect.equal (string NoAutoHtmx) "No" "NoAutoHtmx string incorrect"
}
test "AutoHtmx succeeds" {
Expect.equal (string AutoHtmx) "Yes" "AutoHtmx string incorrect"
}
test "AutoHtmax succeeds" {
Expect.equal (string AutoHtmax) "Max" "AutoHtmax string incorrect"
}
]
]
/// Tests for the CommentStatus type
let commentStatusTests = testList "CommentStatus" [
testList "Parse" [
test "succeeds for \"Approved\"" {
Expect.equal Approved (CommentStatus.Parse "Approved") "Approved not parsed correctly"
Expect.equal (CommentStatus.Parse "Approved") Approved "Approved not parsed correctly"
}
test "succeeds for \"Pending\"" {
Expect.equal Pending (CommentStatus.Parse "Pending") "Pending not parsed correctly"
Expect.equal (CommentStatus.Parse "Pending") Pending "Pending not parsed correctly"
}
test "succeeds for \"Spam\"" {
Expect.equal Spam (CommentStatus.Parse "Spam") "Spam not parsed correctly"
Expect.equal (CommentStatus.Parse "Spam") Spam "Spam not parsed correctly"
}
test "fails for unrecognized value" {
Expect.throwsT<ArgumentException>
@@ -147,13 +177,13 @@ let commentStatusTests = testList "CommentStatus" [
let explicitRatingTests = testList "ExplicitRating" [
testList "Parse" [
test "succeeds for \"yes\"" {
Expect.equal Yes (ExplicitRating.Parse "yes") "\"yes\" not parsed correctly"
Expect.equal (ExplicitRating.Parse "yes") Yes "\"yes\" not parsed correctly"
}
test "succeeds for \"no\"" {
Expect.equal No (ExplicitRating.Parse "no") "\"no\" not parsed correctly"
Expect.equal (ExplicitRating.Parse "no") No "\"no\" not parsed correctly"
}
test "succeeds for \"clean\"" {
Expect.equal Clean (ExplicitRating.Parse "clean") "\"clean\" not parsed correctly"
Expect.equal (ExplicitRating.Parse "clean") Clean "\"clean\" not parsed correctly"
}
test "fails for unrecognized value" {
Expect.throwsT<ArgumentException>
@@ -780,6 +810,7 @@ let uploadDestinationTests = testList "UploadDestination" [
let all = testList "SupportTypes" [
nodaTests
accessLevelTests
autoHtmxTypeTests
commentStatusTests
explicitRatingTests
episodeTests
+4 -4
View File
@@ -1363,7 +1363,7 @@ let settingsModelTests = testList "SettingsModel" [
PostsPerPage = 18
TimeZone = "America/Denver"
ThemeId = ThemeId "my-theme"
AutoHtmx = true
AutoHtmx = AutoHtmx
AutoOpenGraph = false }
Expect.equal model.Name "The Web Log" "Name not filled properly"
Expect.equal model.Slug "the-web-log" "Slug not filled properly"
@@ -1372,7 +1372,7 @@ let settingsModelTests = testList "SettingsModel" [
Expect.equal model.PostsPerPage 18 "PostsPerPage not filled properly"
Expect.equal model.TimeZone "America/Denver" "TimeZone not filled properly"
Expect.equal model.ThemeId "my-theme" "ThemeId not filled properly"
Expect.isTrue model.AutoHtmx "AutoHtmx should have been set"
Expect.equal model.AutoHtmx (string AutoHtmx) "AutoHtmx should have been set"
Expect.equal model.Uploads "Database" "Uploads not filled properly"
Expect.isFalse model.AutoOpenGraph "AutoOpenGraph should have been unset"
}
@@ -1391,7 +1391,7 @@ let settingsModelTests = testList "SettingsModel" [
PostsPerPage = 8
TimeZone = "America/Chicago"
ThemeId = "test-theme"
AutoHtmx = true
AutoHtmx = (string AutoHtmax)
Uploads = "Disk"
AutoOpenGraph = false }.Update WebLog.Empty
Expect.equal webLog.Name "Interesting" "Name not filled properly"
@@ -1401,7 +1401,7 @@ let settingsModelTests = testList "SettingsModel" [
Expect.equal webLog.PostsPerPage 8 "PostsPerPage not filled properly"
Expect.equal webLog.TimeZone "America/Chicago" "TimeZone not filled properly"
Expect.equal webLog.ThemeId (ThemeId "test-theme") "ThemeId not filled properly"
Expect.isTrue webLog.AutoHtmx "AutoHtmx should have been set"
Expect.equal webLog.AutoHtmx AutoHtmax "AutoHtmx should have been set"
Expect.equal webLog.Uploads Disk "Uploads not filled properly"
Expect.isFalse webLog.AutoOpenGraph "AutoOpenGraph should have been unset"
}