forked from sumcumo/vue-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(datepicker): Clear date via delete/backspace key
- Loading branch information
Showing
5 changed files
with
74 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Feature: Clear date on delete | ||
As a user | ||
I want to press the delete or backspace key | ||
So that I can clear the date | ||
|
||
|
||
@id-1 | ||
Scenario Outline: Clear date via "<key>" | ||
Given the calendar has a selected date | ||
When the user focuses the input field and presses "<key>" | ||
Then the date is cleared | ||
And the input field has focus | ||
|
||
Examples: | ||
| # | key | | ||
| 1 | backspace | | ||
| 2 | del | |
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,28 @@ | ||
import { Given, When, Then, And } from 'cypress-cucumber-preprocessor/steps' | ||
|
||
const { createCalendar, focusThe, the } = cy | ||
|
||
describe('Clear date on delete', () => { | ||
describe('@id-1: Clear date via {string}', () => { | ||
Given('the calendar has a selected date', () => { | ||
createCalendar({ | ||
value: new Date(2020, 2, 15), | ||
}) | ||
the('calendar').should('not.be.visible') | ||
the('input').should('have.value', '15 Mar 2020') | ||
}) | ||
|
||
When('the user focuses the input field and presses {string}', (key) => { | ||
// Use force as a non-typeable calendar input is `read-only` | ||
focusThe('input').type(`{${key}}`, { force: true }) | ||
}) | ||
|
||
Then('the date is cleared', () => { | ||
the('input').should('have.value', '') | ||
}) | ||
|
||
And('the input field has focus', () => { | ||
the('input').should('be.focused') | ||
}) | ||
}) | ||
}) |
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