-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for missing style property in ToEvent()
feat: add support for missing style property in ToEvent()
- Loading branch information
Showing
7 changed files
with
221 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,45 @@ | ||
<?php | ||
|
||
use Guava\Calendar\Tests\TestCase; | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Test Case | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The closure you provide to your test functions is always bound to a specific PHPUnit test | ||
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may | ||
| need to change it using the "uses()" function to bind a different classes or traits. | ||
| | ||
*/ | ||
|
||
uses(TestCase::class)->in(__DIR__); | ||
// uses(Tests\TestCase::class)->in('Feature'); | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Expectations | ||
|-------------------------------------------------------------------------- | ||
| | ||
| When you're writing tests, you often need to check that values meet certain conditions. The | ||
| "expect()" function gives you access to a set of "expectations" methods that you can use | ||
| to assert different things. Of course, you may extend the Expectation API at any time. | ||
| | ||
*/ | ||
|
||
expect()->extend('toBeOne', function () { | ||
return $this->toBe(1); | ||
}); | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Functions | ||
|-------------------------------------------------------------------------- | ||
| | ||
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your | ||
| project that you don't want to repeat in every file. Here you can also expose helpers as | ||
| global functions to help you to reduce the number of lines of code in your test files. | ||
| | ||
*/ | ||
|
||
function something() | ||
{ | ||
// .. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?php | ||
|
||
use Carbon\Carbon; | ||
use Guava\Calendar\ValueObjects\Event; | ||
|
||
beforeEach(function () { | ||
$this->event = Event::make(); | ||
}); | ||
|
||
it('should set start and end', function () { | ||
$start = Carbon::now(); | ||
$end = Carbon::now()->addHour(); | ||
|
||
$this->event->start($start); | ||
$this->event->end($end); | ||
|
||
expect($this->event->getStart())->toBe($start); | ||
expect($this->event->getEnd())->toBe($end); | ||
}); | ||
|
||
it('should set all day', function () { | ||
$this->event->allDay(true); | ||
|
||
expect($this->event->getAllDay())->toBeTrue(); | ||
}); | ||
|
||
it('should set the title', function () { | ||
$title = 'Test Event'; | ||
$this->event->title($title); | ||
|
||
expect($this->event->getTitle())->toBe($title); | ||
}); | ||
|
||
it('should set the background color', function () { | ||
$color = '#ff0000'; | ||
$this->event->backgroundColor($color); | ||
|
||
expect($this->event->getBackgroundColor())->toBe($color); | ||
}); | ||
|
||
it('should set the text color', function () { | ||
$color = '#00ff00'; | ||
$this->event->textColor($color); | ||
|
||
expect($this->event->getTextColor())->toBe($color); | ||
}); | ||
|
||
it('should set the styles', function () { | ||
$styles = [ | ||
'color: red', | ||
'display: flex; flex-direction: row;', | ||
'font-size' => '12px', | ||
'opacity' => 1, | ||
'background-color: blue' => false, | ||
'border-color: red' => true, | ||
]; | ||
$this->event->styles($styles); | ||
|
||
expect($this->event->getStyles())->toBe('color: red; display: flex; flex-direction: row; font-size: 12px; opacity: 1; border-color: red;'); | ||
}); | ||
|
||
it('should set the display', function () { | ||
$display = 'block'; | ||
$this->event->display($display); | ||
|
||
expect($this->event->getDisplay())->toBe($display); | ||
}); | ||
|
||
it('should set the editable features', function () { | ||
$this->event->editable(true); | ||
expect($this->event->getEditable())->toBeTrue(); | ||
|
||
$this->event->startEditable(true); | ||
expect($this->event->getStartEditable())->toBeTrue(); | ||
|
||
$this->event->durationEditable(true); | ||
expect($this->event->getDurationEditable())->toBeTrue(); | ||
}); | ||
|
||
it('should set resource ids', function () { | ||
$resourceIds = [1, 2, 3]; | ||
$this->event->resourceIds($resourceIds); | ||
|
||
expect($this->event->getResourceIds())->toBe($resourceIds); | ||
}); | ||
|
||
it('should set some extended props', function () { | ||
$props = ['key' => 'value', 'another_key' => 'another_value']; | ||
$this->event->extendedProps($props); | ||
|
||
expect($this->event->getExtendedProps())->toBe($props); | ||
}); | ||
|
||
it('should return props to array', function () { | ||
$start = Carbon::now(); | ||
$end = Carbon::now()->addHour(); | ||
$title = 'Test Event'; | ||
$backgroundColor = '#ff0000'; | ||
$textColor = '#00ff00'; | ||
$styles = ['color' => 'red', 'font-size' => '12px', 'background-color' => false, 'border-color: red' => true]; | ||
$resourceIds = [1, 2, 3]; | ||
$extendedProps = ['key' => 'value', 'another_key' => 'another_value']; | ||
|
||
$this->event->start($start)->end($end)->title($title)->backgroundColor($backgroundColor) | ||
->textColor($textColor)->styles($styles)->resourceIds($resourceIds)->extendedProps($extendedProps) | ||
; | ||
|
||
$array = $this->event->toArray(); | ||
|
||
expect($array)->toMatchArray([ | ||
'title' => $title, | ||
'start' => $start, | ||
'end' => $end, | ||
'backgroundColor' => $backgroundColor, | ||
'textColor' => $textColor, | ||
'styles' => 'color: red; font-size: 12px; border-color: red;', | ||
'resourceIds' => $resourceIds, | ||
'extendedProps' => $extendedProps, | ||
]); | ||
}); |