From 830e7c5d27d161b91402414e6ecd49f1ed818bfb Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Fri, 27 Mar 2026 08:48:05 +0100 Subject: Initial commit --- lib/model/tests/parent.t | 91 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 lib/model/tests/parent.t (limited to 'lib/model/tests/parent.t') diff --git a/lib/model/tests/parent.t b/lib/model/tests/parent.t new file mode 100644 index 0000000..8e77578 --- /dev/null +++ b/lib/model/tests/parent.t @@ -0,0 +1,91 @@ + +A root content does not have any parent + + $ tests -parent "entity" < { + > "content": [ + > { + > "id": "entity" + > } + > ] + > } + > EOF + [No parent] + +A root content is the root of itself + + $ tests -parent -root "entity" < { + > "content": [ + > { + > "id": "entity" + > } + > ] + > } + > EOF + "entity" + +The parent of a subcontent shall never been None, and will target the container + + $ tests -parent "details" < { + > "content": [ + > { + > "id": "entity", + > "subcontent": [ + > { + > "id": "details" + > } + > ] + > } + > ] + > } + > EOF + "entity" + +The parent element can be a subcontent itself + + $ tests -parent "level2" < { + > "content": [ + > { + > "id": "entity", + > "subcontent": [ + > { + > "id": "level1", + > "subcontent": [ + > { + > "id": "level2" + > } + > ] + > } + > ] + > } + > ] + > } + > EOF + "level1" + +The root element is the top content + + $ tests -parent -root "level2" < { + > "content": [ + > { + > "id": "entity", + > "subcontent": [ + > { + > "id": "level1", + > "subcontent": [ + > { + > "id": "level2" + > } + > ] + > } + > ] + > } + > ] + > } + > EOF + "entity" + -- cgit v1.2.3