我有一个像这样的请求构建器:
login : { r | usernameOrEmail : String, password : String } -> Http.Request Token
login { usernameOrEmail, password } =
let
body =
Http.jsonBody <|
Encode.object
[ ("username_or_email", Encode.string usernameOrEmail)
, ("password", Encode.string password)
]
in
Http.post (apiUrl "/auth/login/") body Token.decoder
我可以通过从 elm-lang / http 调用发送来使用它:
Http.send LoginCompleted (login model)
如何为此代码编写单元测试?具体来说,我想测试我的请求构建器。