Skip to content

Commit

Permalink
add an integration test for #57, fixes #56; Release v3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
changhuixu committed Sep 7, 2021
1 parent 4661e02 commit 5cdbf41
Show file tree
Hide file tree
Showing 8 changed files with 393 additions and 352 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"beforeinput"
]
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

## CHANGELOG

- **v3.2.0**: `digitOnly` directive now supports disabling paste events (merges a pull request [#57](/../../pull/49), fixes [#56](/../../issues/56)).

- **v3.1.0**(**v2.3.0**): `digitOnly` directive now supports negative values (merges a pull request [#49](/../../pull/49)).

- **v3.0.0**: a release on par with Angular 12. For projects in Angular v10 or v11, please use v2 of this library.
Expand Down
21 changes: 20 additions & 1 deletion cypress/integration/clipboard-events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe('Copy & Paste', () => {
cy.get('#digit-only-decimal').clear();
});

it('s', ()=> {
it('s', () => {
const dt = new DataTransfer();
dt.setData('text/plain', 'abc1.0s.1');
const pasteEvent = new ClipboardEvent('paste', {
Expand Down Expand Up @@ -288,4 +288,23 @@ describe('Copy & Paste', () => {

cy.get('#negative-digit-only').clear();
});

it('should disable paste when [allowPaste] is false', () => {
const dt = new DataTransfer();
dt.setData('text/plain', 'a-123');
const pasteEvent = new ClipboardEvent('paste', {
clipboardData: dt,
bubbles: true,
cancelable: true,
});

cy.get('#digit-only-disable-paste').clear();

cy.get('#digit-only-disable-paste').then(($el) => {
$el[0].dispatchEvent(pasteEvent);
cy.get('#digit-only-disable-paste').should('have.value', '');
});

cy.get('#digit-only-disable-paste').clear();
});
});
Loading

0 comments on commit 5cdbf41

Please sign in to comment.