Testing component with Context
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start with the Wrapper component's from_context: :navigation declaration and the render_surface and compile_surface calls shown in the issue. Determine how context should be supplied during component tests, then verify that rendering Wrapper with navigation items no longer produces a nil-list error.
Written by the indexing model from the issue text.
Description
Hi,
I am trying to perform a test on a component that retrieves a value from the context and I can't find a proper way to achieve it.
Say I have the following Wrapper live component:
data items, :list, from_context: :navigation
def render(assigns) do
~F"""
<div>
<Navigation items={@items} />
</div>
"""
end
I tried to pass the items through the use_config macro like this:
using_config Wrapper, items: [1, 2, 3] do
html = render_surface do
~F"""
<Wrapper id="navigation" />
"""
end
end
but it throws a runtime error saying items is nil (not a valid list).
Is there a way to provide the render_surface with a context? Or perhaps to use something other than render_surface, say compile_surface (I tried that macro as well to no avail).
- Dominant language
- Elixir
- Stars
- 2.1k
- Forks
- 146
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from surface-ui/surface
-
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
surface-ui/surface#634 · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
surface-ui/surface#770 ·
-
Website is down Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
surface-ui/surface#768 · 4 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
surface-ui/surface#762 · 2 comments · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
surface-ui/surface#759 · 1 reaction ·
All issues in surface-ui/surface
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
phoenixframework/phoenix#6847 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
beyond-all-reason/teiserver#1584 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ash-project/ash#2954 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
membraneframework/boombox#149 ·