-- 폼 제출 테스트: 핸들러 안에서 FormData 를 객체로 바꿔 비교한다 submitted :: Form -> Map Name Value submitted = fromEntries . entries . formData -- new FormData(e.target) → Object.fromEntries test = do change "아이디" "testuser" ; change "비밀번호" "password" ; click "로그인" submitted form `shouldBe` fromList [("username", "testuser"), ("password", "password")] handleSubmit `shouldHaveBeenCalled` () -- preventDefault 는 핸들러 안에서
-- 파일 업로드: FormData 에 담아 body 로 formData :: File -> [File] -> FormData formData single multiple = ("single", single) : [("multiple_" ++ show i, f) | (i, f) <- zip [0 ..] multiple] -- fetch(url, { method: 'POST', body: formData })