Skip to content

Commit

Permalink
Add annotations unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mariosimao committed Oct 20, 2021
1 parent c1cea7f commit 0c49286
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Common/Annotations.php
Expand Up @@ -173,6 +173,8 @@ public function code(bool $code = true): self

public function withColor(string $color): self
{
$this->checkColor($color);

return new self(
$this->bold,
$this->italic,
Expand Down
69 changes: 69 additions & 0 deletions tests/Unit/Common/AnnotationsTest.php
@@ -0,0 +1,69 @@
<?php

namespace Notion\Test\Common;

use Notion\Common\Annotations;
use PHPUnit\Framework\TestCase;

class AnnotationsTest extends TestCase
{
public function test_without_annotations(): void
{
$annotations = Annotations::create();

$this->assertFalse($annotations->isBold());
$this->assertFalse($annotations->isItalic());
$this->assertFalse($annotations->isStrikeThrough());
$this->assertFalse($annotations->isUnderline());
$this->assertFalse($annotations->isCode());
$this->assertEquals("default", $annotations->color());
}

public function test_bold(): void
{
$annotations = Annotations::create()->bold();

$this->assertTrue($annotations->isBold());
}

public function test_italic(): void
{
$annotations = Annotations::create()->italic();

$this->assertTrue($annotations->isItalic());
}

public function test_strike_through(): void
{
$annotations = Annotations::create()->strikeThrough();

$this->assertTrue($annotations->isStrikeThrough());
}

public function test_underline(): void
{
$annotations = Annotations::create()->underline();

$this->assertTrue($annotations->isUnderline());
}

public function test_code(): void
{
$annotations = Annotations::create()->code();

$this->assertTrue($annotations->isCode());
}

public function test_change_color(): void
{
$annotations = Annotations::create()->withColor("red");

$this->assertEquals("red", $annotations->color());
}

public function test_change_unsupported_color(): void
{
$this->expectException(\Exception::class);
Annotations::create()->withColor("not-a-color");
}
}

0 comments on commit 0c49286

Please sign in to comment.