Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions tests/test_id_tail.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""An element file's id tail is the last 8 code points of its id (folder spec 3.2): an id with a character above
U+FFFF in its tail, or at the cut, names its file as the npm SDK names it (``test/id-tail.test.mjs`` there holds the
same two cases), and ``write_folder`` writes that name to disk."""
U+FFFF in its tail, or at the cut, names its file as the npm SDK names it, and dashes are kept unless the cut of
eight begins with one or holds two, when the tail is cut from the id with every dash removed. The five cases are the
folder spec's own and the same as the npm SDK's ``test/id-tail.test.mjs``; ``write_folder`` writes each name to
disk."""

from __future__ import annotations

Expand All @@ -19,9 +21,12 @@
[
(f"a1234567{E}", f"bob--1234567{E}.json"),
(f"a{E}1234567", f"bob--{E}1234567.json"),
("ab-cd-ef-gh1", "bob--d-ef-gh1.json"),
("abcd-efghijk", "bob--defghijk.json"),
("abc--defghij", "bob--cdefghij.json"),
],
)
def test_a_character_above_the_bmp_counts_as_one(tmp_path: Path, element_id: str, name: str) -> None:
def test_the_tail_of_eight_code_points(tmp_path: Path, element_id: str, name: str) -> None:
assert element_filename(element_id, "Bob") == name
out = tmp_path / "world"
write_folder(out, {"id": "w-1", "name": "W"}, {"character": [{"id": element_id, "name": "Bob"}]})
Expand Down