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:
@@ -6,6 +6,20 @@ open MyWebLog
|
||||
open MyWebLog.Converters.Json
|
||||
open Newtonsoft.Json
|
||||
|
||||
/// Unit tests for the AutoHtmxTypeConverter type
|
||||
let autoHtmxTypeConverterTests = testList "AutoHtmxTypeConverter" [
|
||||
let opts = JsonSerializerSettings()
|
||||
opts.Converters.Add(AutoHtmxTypeConverter())
|
||||
test "succeeds when serializing" {
|
||||
let after = JsonConvert.SerializeObject(AutoHtmax, opts)
|
||||
Expect.equal after "\"Max\"" "Auto htmx type serialized incorrectly"
|
||||
}
|
||||
test "succeeds when deserializing" {
|
||||
let after = JsonConvert.DeserializeObject<AutoHtmxType>("\"Yes\"", opts)
|
||||
Expect.equal after AutoHtmx "Auto htmx type not serialized incorrectly"
|
||||
}
|
||||
]
|
||||
|
||||
/// Unit tests for the CategoryIdConverter type
|
||||
let categoryIdConverterTests = testList "CategoryIdConverter" [
|
||||
let opts = JsonSerializerSettings()
|
||||
@@ -264,6 +278,7 @@ open NodaTime.Serialization.JsonNet
|
||||
let configureTests = test "Json.configure succeeds" {
|
||||
let has typ (converter: JsonConverter) = converter.GetType() = typ
|
||||
let ser = configure (JsonSerializer.Create())
|
||||
Expect.hasCountOf ser.Converters 1u (has typeof<AutoHtmxTypeConverter>) "Auto htmx type converter not found"
|
||||
Expect.hasCountOf ser.Converters 1u (has typeof<CategoryIdConverter>) "Category ID converter not found"
|
||||
Expect.hasCountOf ser.Converters 1u (has typeof<CommentIdConverter>) "Comment ID converter not found"
|
||||
Expect.hasCountOf ser.Converters 1u (has typeof<CommentStatusConverter>) "Comment status converter not found"
|
||||
@@ -290,6 +305,7 @@ let configureTests = test "Json.configure succeeds" {
|
||||
|
||||
/// All tests for the Data.Converters file
|
||||
let all = testList "Converters" [
|
||||
autoHtmxTypeConverterTests
|
||||
categoryIdConverterTests
|
||||
commentIdConverterTests
|
||||
commentStatusConverterTests
|
||||
|
||||
Reference in New Issue
Block a user