Skip to content
This repository was archived by the owner on Apr 21, 2022. It is now read-only.

Commit 919f54a

Browse files
committed
Add preview to tests
1 parent 232a3c5 commit 919f54a

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/FilamentColorPickerServiceProvider.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ final class FilamentColorPickerServiceProvider extends PluginServiceProvider
1818
'rvxlab-filament-colorpicker' => __DIR__ . '/../resources/dist/filament-colorpicker.js',
1919
];
2020

21+
/**
22+
* @var string[]
23+
*/
2124
protected array $styles = [
2225
'rvxlab-filament-colorpicker' => __DIR__ . '/../resources/dist/filament-colorpicker.css',
2326
];

src/Forms/ColorPicker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function getDebounceTimeout(): int
164164
}
165165

166166
/**
167-
* @return array{editorFormat: string, popupPosition: ?string, alpha: bool, layout: string, cancelButton: bool, statePath: string, template: ?string, debounceTimeout: int}
167+
* @return array{editorFormat: string, popupPosition: ?string, alpha: bool, layout: string, cancelButton: bool, statePath: string, template: ?string, debounceTimeout: int, preview: bool}
168168
*/
169169
public function getPickerOptions(): array
170170
{

tests/Feature/ColorPickerTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function testDefaults(): void
2727
'statePath' => 'color',
2828
'template' => null,
2929
'debounceTimeout' => 500,
30+
'preview' => false,
3031
], $field->getPickerOptions());
3132
}
3233

@@ -48,6 +49,7 @@ public function testWithCustomOptions(): void
4849
'statePath' => 'color',
4950
'template' => null,
5051
'debounceTimeout' => 500,
52+
'preview' => false,
5153
], $field->getPickerOptions());
5254
}
5355

@@ -65,6 +67,7 @@ public function testPopupDisabled(): void
6567
'statePath' => 'color',
6668
'template' => null,
6769
'debounceTimeout' => 500,
70+
'preview' => false,
6871
], $field->getPickerOptions());
6972

7073
self::assertFalse($field->isPopupEnabled());
@@ -86,9 +89,27 @@ public function testWithCustomTemplate(): void
8689
'statePath' => 'color',
8790
'template' => '<div>This is a test template</div>',
8891
'debounceTimeout' => 500,
92+
'preview' => false,
8993
], $field->getPickerOptions());
9094
}
9195

96+
public function testWithPreview(): void
97+
{
98+
$field = $this->makeComponent()
99+
->preview();
100+
101+
self::assertEquals([
102+
'editorFormat' => 'hex',
103+
'popupPosition' => 'right',
104+
'alpha' => true,
105+
'layout' => 'default',
106+
'cancelButton' => false,
107+
'statePath' => 'color',
108+
'template' => null,
109+
'debounceTimeout' => 500,
110+
'preview' => true,
111+
], $field->getPickerOptions());
112+
}
92113
private function makeComponent(): ColorPicker
93114
{
94115
return tap(new ColorPicker('color'), function (ColorPicker $field): void {

0 commit comments

Comments
 (0)