livebook/test/live_book/notebook_test.exs
Jonatan Kłosko 936d0af5fb
Set up markdown rendering (#16)
* Set up markdown rendering, update theme.

* Improve focus and handle expanding for markdown cells

* Add keybindings for expanding/navigating cells

* Improve editor autofocus when navigating with shortcuts

* Add tests

* Render markdown on the client

* Don't render cell initial data and make a request instead
2021-01-30 00:33:04 +01:00

48 lines
1.5 KiB
Elixir

defmodule LiveBook.NotebookTest do
use ExUnit.Case, async: true
alias LiveBook.Notebook
alias LiveBook.Notebook.{Section, Cell}
describe "fetch_cell_sibling/3" do
test "returns error given invalid cell id" do
notebook = Notebook.new()
assert :error == Notebook.fetch_cell_sibling(notebook, "1", 0)
end
test "returns sibling cell if there is one at the given offset" do
cell1 = %{Cell.new(:markdown) | id: "1"}
cell2 = %{Cell.new(:markdown) | id: "2"}
cell3 = %{Cell.new(:markdown) | id: "3"}
cell4 = %{Cell.new(:markdown) | id: "4"}
notebook = %{
Notebook.new()
| sections: [
%{Section.new() | cells: [cell1, cell2, cell3, cell4]}
]
}
assert {:ok, cell1} == Notebook.fetch_cell_sibling(notebook, cell2.id, -1)
assert {:ok, cell3} == Notebook.fetch_cell_sibling(notebook, cell2.id, 1)
assert {:ok, cell4} == Notebook.fetch_cell_sibling(notebook, cell2.id, 2)
end
test "returns error if the offset is out of range" do
cell1 = %{Cell.new(:markdown) | id: "1"}
cell2 = %{Cell.new(:markdown) | id: "2"}
notebook = %{
Notebook.new()
| sections: [
%{Section.new() | cells: [cell1, cell2]}
]
}
assert :error == Notebook.fetch_cell_sibling(notebook, cell2.id, -2)
assert :error == Notebook.fetch_cell_sibling(notebook, cell2.id, 1)
assert :error == Notebook.fetch_cell_sibling(notebook, cell2.id, 2)
end
end
end