livebook/test/livebook_web/helpers_test.exs
Cristine Guadelupe 4dd28388a5
Bulk actions for sessions (#939)
* Initial implementation to close multiple sessions

* Sessions: bulk actions with components

* Rename Disconnect sessions to Disconnect runtime

* Select all and disabled when nothing is selected

* Styled checkbox

* Renames toggle events

* Warning about not persisted notebooks

* Adds disconnect runtime option for a single session

* Edit sessions on right

* Fix: typos and plural

* Minor adjustments

* Removes the loop for rendering the menu

* Menus with fixed width

* Minor adjustments

* Pluralize as global helper

* Bulk actions form on client side

* Track bulk actions buttons state

* Fix: home live tests

* Doctests for pluralize

* Fix: bulk actions buttons losing state on session update

* Fix: format

* Minor adjustment on toggle_edit

* Review-based adjustments

* Reset the Edit state after single-session actions

* Minor adjustments

* Fixes bulk action events

* Submit the bulk action form directly

* Tests for bulk actions

* Indentation

* Update lib/livebook_web/live/home_live/close_session_component.ex

Co-authored-by: José Valim <jose.valim@gmail.com>

Co-authored-by: José Valim <jose.valim@gmail.com>
2022-01-28 17:45:04 -03:00

62 lines
1.7 KiB
Elixir
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

defmodule LivebookWeb.HelpersTest do
use ExUnit.Case, async: true
alias LivebookWeb.Helpers
doctest Helpers
describe "names_to_html_ids/1" do
test "title case" do
assert(Helpers.names_to_html_ids(["Title of a Section"]) == ["title-of-a-section"])
end
# Contains a couple of unicode spaces to ensure that we handle those
test "space characters" do
assert Helpers.names_to_html_ids([" slug \n with spaces \t "]) == ["slug-with-spaces"]
end
test "emoji at end" do
assert Helpers.names_to_html_ids(["Test 🦦 "]) == ["test-🦦"]
end
test "emoji in middle" do
assert Helpers.names_to_html_ids(["One 🥮 Two"]) == ["one-🥮-two"]
end
test "returns empty list for an empty list" do
assert Helpers.names_to_html_ids([]) == []
end
test "returns id-ified strings for different kinds of names" do
names = [
"Title of a Section",
" something with \n many space characters \t "
]
assert Helpers.names_to_html_ids(names) == [
"title-of-a-section",
"something-with-many-space-characters"
]
end
test "enumerates ids when they would be the same" do
names = [
"Title of a Section",
"Some other title",
" Title of a Section",
"random",
" Title of a section",
"Title of a Section "
]
assert Helpers.names_to_html_ids(names) == [
"title-of-a-section",
"some-other-title",
"title-of-a-section-2",
"random",
"title-of-a-section-3",
"title-of-a-section-4"
]
end
end
end