feat: Adds multi-step form to generate equivalent lengths for a project.
This commit is contained in:
@@ -72,4 +72,34 @@ struct ProjectRouteTests {
|
||||
let route = try router.parse(&request)
|
||||
#expect(route == .project(.index))
|
||||
}
|
||||
|
||||
@Test
|
||||
func formData() throws {
|
||||
let p = Body {
|
||||
FormData {
|
||||
Optionally {
|
||||
Field("id", default: nil) { EffectiveLength.ID.parser() }
|
||||
}
|
||||
Field("projectID") { Project.ID.parser() }
|
||||
Field("name", .string)
|
||||
Field("type") { EffectiveLength.EffectiveLengthType.parser() }
|
||||
Many {
|
||||
Field("straightLengths") {
|
||||
Int.parser()
|
||||
}
|
||||
}
|
||||
}
|
||||
.map(.memberwise(SiteRoute.View.ProjectRoute.EquivalentLengthRoute.StepTwo.init))
|
||||
}
|
||||
|
||||
var request = URLRequestData(
|
||||
body: .init(
|
||||
"projectID=15062A72-7AB5-4F15-9B1F-74A4BFA53CBB&name=Test&type=supply&straightLengths=20&straightLengths=10"
|
||||
.utf8
|
||||
)
|
||||
)
|
||||
let value = try p.parse(&request)
|
||||
print(value)
|
||||
#expect(value.straightLengths == [20, 10])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user