Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing component with Context #756

Open
jpyamamoto opened this issue Oct 17, 2024 · 0 comments
Open

Testing component with Context #756

jpyamamoto opened this issue Oct 17, 2024 · 0 comments

Comments

@jpyamamoto
Copy link

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant