Skip to content

Commit 17f5094

Browse files
committed
Add new nested test
1 parent 4e32477 commit 17f5094

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

tests/GeneralTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,21 @@ public function testBlocksContent()
9696

9797
$this->assertException($callable, EditorJSException::class, null, 'Block must be an Array');
9898
}
99+
100+
public function testNested()
101+
{
102+
$data = '{"blocks":[{"type":"table","data":{"header": {"description":"a table", "author": "codex"}, "rows": [["name", "age", "sex"],["Paul", "24", "male"],["Ann", "26", "female"]]}}]}';
103+
$editor = new EditorJS($data, $this->config);
104+
$result = $editor->getBlocks();
105+
106+
$valid_rows = [["name", "age", "sex"],["Paul", "24", "male"],["Ann", "26", "female"]];
107+
108+
$this->assertEquals('a table', $result[0]['data']['header']['description']);
109+
$this->assertEquals('codex', $result[0]['data']['header']['author']);
110+
$this->assertEquals(3, count($result[0]['data']['rows']));
111+
112+
$this->assertEquals('name', $result[0]['data']['rows'][0][0]);
113+
$this->assertEquals('24', $result[0]['data']['rows'][1][1]);
114+
$this->assertEquals('female', $result[0]['data']['rows'][2][2]);
115+
}
99116
}

tests/samples/test-config.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,32 @@
4343
"type": "string",
4444
"canBeOnly": ["left", "center"]
4545
}
46+
},
47+
"table": {
48+
"header": {
49+
"type": "array",
50+
"data": {
51+
"description": {
52+
"type": "string"
53+
},
54+
"author": {
55+
"type": "string"
56+
}
57+
}
58+
},
59+
"rows": {
60+
"type": "array",
61+
"data": {
62+
"-": {
63+
"type": "array",
64+
"data": {
65+
"-": {
66+
"type": "string"
67+
}
68+
}
69+
}
70+
}
71+
}
4672
}
4773
}
4874
}

0 commit comments

Comments
 (0)