Phoenix.LiveViewTest.render_upload
You're seeing just the function
render_upload
, go back to Phoenix.LiveViewTest module for more information.
Performs an upload of a file input and renders the result.
See file_input/4
for details on building a file input.
Examples
Given the following LiveView template:
<%= for entry <- @uploads.avatar.entries %>
<%=entry.name %>: <%= entry.progress %>%
<% end %>
Your test case can assert the uploaded content:
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%"
By default, the entire file is chunked to the server, but an optional percentage to chunk can be passed to test chunk-by-chunk uploads:
assert render_upload(avatar, "foo.jpeg", 49) =~ "49%"
assert render_upload(avatar, "foo.jpeg", 51) =~ "100%"