Phoenix.LiveViewTest.file_input
You're seeing just the macro
file_input
, go back to Phoenix.LiveViewTest module for more information.
Builds a file input for testing uploads within a form.
Given the form DOM selector, the upload name, and a list of maps of client metadata
for the upload, the returned file input can be passed to render_upload/2
.
Client metadata takes the following form:
:last_modified
- the last modified timestamp:name
- the name of the file:content
- the binary content of the file:size
- the byte size of the content:type
- the MIME type of the file
Examples
avatar = file_input(lv, "#my-form-id", :avatar, [%{
last_modified: 1_594_171_879_000,
name: "myfile.jpeg",
content: File.read!("myfile.jpg"),
size: 1_396_009,
type: "image/jpeg"
}])
assert render_upload(avatar, "foo.jpeg") =~ "100%"