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
28 changes: 28 additions & 0 deletions tests/test_id_tail.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""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."""

from __future__ import annotations

from pathlib import Path

import pytest

from onlyworlds import write_folder
from onlyworlds.folder import element_filename

E = chr(0x1F600)


@pytest.mark.parametrize(
("element_id", "name"),
[
(f"a1234567{E}", f"bob--1234567{E}.json"),
(f"a{E}1234567", f"bob--{E}1234567.json"),
],
)
def test_a_character_above_the_bmp_counts_as_one(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"}]})
assert [p.name for p in (out / "elements" / "character").iterdir()] == [name]