From dbbd86bf61b07f4b3ca0d57aa12fe69c4d4ee9f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Sim=C3=A3o?= Date: Fri, 5 May 2023 21:27:03 -0300 Subject: [PATCH] More tests --- tests/Unit/Blocks/ToggleTest.php | 3 +-- tests/Unit/Databases/DatabaseParentTest.php | 11 +++++++++++ tests/Unit/Pages/PageParentTest.php | 11 +++++++++++ tests/Unit/Pages/Properties/DateTest.php | 1 + 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/Unit/Blocks/ToggleTest.php b/tests/Unit/Blocks/ToggleTest.php index 71fa28eb..a2325784 100644 --- a/tests/Unit/Blocks/ToggleTest.php +++ b/tests/Unit/Blocks/ToggleTest.php @@ -3,7 +3,6 @@ namespace Notion\Test\Unit\Blocks; use Notion\Blocks\BlockFactory; -use Notion\Blocks\ToDo; use Notion\Exceptions\BlockException; use Notion\Blocks\Toggle; use Notion\Common\Color; @@ -190,7 +189,7 @@ public function test_add_child(): void public function test_change_color(): void { - $block = ToDo::fromString("Hello World!")->changeColor(Color::Red); + $block = Toggle::fromString("Hello World!")->changeColor(Color::Red); $this->assertSame(Color::Red, $block->color); } diff --git a/tests/Unit/Databases/DatabaseParentTest.php b/tests/Unit/Databases/DatabaseParentTest.php index 43847f17..52d6383a 100644 --- a/tests/Unit/Databases/DatabaseParentTest.php +++ b/tests/Unit/Databases/DatabaseParentTest.php @@ -53,6 +53,17 @@ public function test_workspace_array_conversion(): void $this->assertEquals($array["workspace"], $parent->toArray()["workspace"]); } + public function test_block_array_conversion(): void + { + $array = [ + "type" => "block_id", + "block_id" => "7a774b5d-ca74-4679-9f18-689b5a98f138", + ]; + $parent = DatabaseParent::fromArray($array); + + $this->assertEquals($array["block_id"], $parent->toArray()["block_id"]); + } + public function test_invalid_type_array(): void { $this->expectException(\ValueError::class); diff --git a/tests/Unit/Pages/PageParentTest.php b/tests/Unit/Pages/PageParentTest.php index 93781878..89bf65b4 100644 --- a/tests/Unit/Pages/PageParentTest.php +++ b/tests/Unit/Pages/PageParentTest.php @@ -73,6 +73,17 @@ public function test_workspace_array_conversion(): void $this->assertEquals($array["workspace"], $parent->toArray()["workspace"]); } + public function test_block_array_conversion(): void + { + $array = [ + "type" => "block_id", + "block_id" => "7a774b5d-ca74-4679-9f18-689b5a98f138", + ]; + $parent = PageParent::fromArray($array); + + $this->assertEquals($array["block_id"], $parent->toArray()["block_id"]); + } + public function test_invalid_type_array(): void { $this->expectException(\ValueError::class); diff --git a/tests/Unit/Pages/Properties/DateTest.php b/tests/Unit/Pages/Properties/DateTest.php index 4c5b89cc..11ff343e 100644 --- a/tests/Unit/Pages/Properties/DateTest.php +++ b/tests/Unit/Pages/Properties/DateTest.php @@ -92,5 +92,6 @@ public function test_is_empty(): void $date = Date::fromArray($array); $this->assertTrue($date->isEmpty()); + $this->assertFalse($date->isRange()); } }