# `Narabe.Test`
[🔗](https://github.com/hattoriai/narabe/blob/v0.1.0/lib/narabe/test.ex#L1)

Helpers for `Phoenix.LiveViewTest`, to move, open, rename and pick in
tests with no browser.

    import Narabe.Test

    test "moves a card to Done", %{conn: conn} do
      {:ok, view, _html} = live(conn, ~p"/boards/1")

      move(view, "board", card.id, parent: done.id, index: 0)
      assert_reply(view, %{ok: true})
      assert {"Done", ["Write the docs", "Ship"]} in columns(view, "board")
    end

`move/4` sends the list's `on_move` event with the move as the browser
sends it (`Narabe.Move.to_params/1`), to the LiveView or the component of
the list's `phx-target`; the reply is the LiveView's (`assert_reply/2`).
The page shows what the server renders next: unlike a browser, the test
does not move anything first.

# `columns`

```elixir
@spec columns(struct(), String.t()) :: [{String.t(), [String.t()]}]
```

A board's columns, in order: `{label, card labels}`.

# `expand`

```elixir
@spec expand(struct(), String.t(), term()) :: String.t()
```

Opens a tree item whose children are not loaded: sends `on_expand`.

# `items`

```elixir
@spec items(struct(), String.t()) :: [String.t()]
```

The labels of a list's items (a board's cards, a tree's loaded items), in order.

# `move`

```elixir
@spec move(struct(), String.t(), term() | [term()], keyword()) :: String.t()
```

Moves items (an id or a list of ids) of the list, tree or board with
the id `list_id`, and returns the rendered LiveView.

Options: `:after`, `:before` (a neighbour's id), `:parent` (a tree
item's or a board column's id), `:index` (its place among its new
siblings), and `columns: true` for a board's columns.

# `outline`

```elixir
@spec outline(struct(), String.t()) :: [{String.t(), pos_integer()}]
```

A tree's loaded items, in order: `{label, level}`, the top level being 1.

# `pick`

```elixir
@spec pick(struct(), String.t(), term()) :: String.t()
```

Picks an item of a tree picker in a form, as a click does: the form's
`phx-change` with the item's id. The form must have an `id`.

# `rename`

```elixir
@spec rename(struct(), String.t(), term(), String.t()) :: String.t()
```

Renames a tree item: sends `on_rename`.

# `select`

```elixir
@spec select(struct(), String.t(), [term()]) :: String.t()
```

Selects items: sends `on_select`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
