diff --git a/tests/Browser/DatepickerTest.php b/tests/Browser/DatepickerTest.php
index adb8faff..6e70b44d 100644
--- a/tests/Browser/DatepickerTest.php
+++ b/tests/Browser/DatepickerTest.php
@@ -33,10 +33,10 @@ class DateProbe extends Component
trip: {{ json_encode($trip) }}
renders: {{ $renders }}
-
+
-
+
BLADE;
}
@@ -296,3 +296,18 @@ it('opens a docked picker as a modal one on a compact window', function () {
->assertScript("document.querySelector('#expires-field-picker').matches(':modal')")
->assertScript("getComputedStyle(document.querySelector('#expires-field-picker [data-datepicker-header]')).display !== 'none'");
});
+
+it('empties a date, or both ends of a range, with its clear button', function () {
+ $page = dateProbe()
+ ->assertScript("getComputedStyle(document.querySelector('#expires-field').closest('.field').querySelector('[data-field-clear]')).display !== 'none'");
+
+ $page->click('[data-datepicker]:has(#expires-field) [data-field-clear]')
+ ->assertScript("document.querySelector('#expires').textContent === ''")
+ ->assertValue('#expires-field', '')
+ ->assertScript("document.activeElement.id === 'expires-field'")
+ ->assertScript("getComputedStyle(document.querySelector('[data-datepicker]:has(#expires-field) [data-field-clear]')).display === 'none'");
+
+ $page->click('[data-datepicker]:has(#trip-field) [data-field-clear]')
+ ->assertSeeIn('#trip', '{"start":null,"end":null}')
+ ->assertValue('#trip-field', '');
+});
diff --git a/tests/Feature/Components/DatepickerTest.php b/tests/Feature/Components/DatepickerTest.php
index c8910a48..750d1ee2 100644
--- a/tests/Feature/Components/DatepickerTest.php
+++ b/tests/Feature/Components/DatepickerTest.php
@@ -163,3 +163,12 @@ it('replaces the hint with the errors for the property and its start and end', f
->toContain('data-datepicker-error')
->and(substr_count($html, 'data-invalid=""'))->toBe(2);
});
+
+it('offers a clear button on request', function () {
+ expect((string) $this->blade('