generated from Tinkoff/angular-open-source-starter
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(kit):
Number
should drop decimal separator if all digits are er…
…ased
- Loading branch information
1 parent
ed06936
commit bd80c7d
Showing
2 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
projects/demo-integrations/src/tests/component-testing/number/alone-decimal-separator.cy.ts
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,55 @@ | ||
import {maskitoNumberOptionsGenerator} from '@maskito/kit'; | ||
|
||
import {TestInput} from '../utils'; | ||
|
||
describe('Number | should drop decimal separator if all digits are erased', () => { | ||
beforeEach(() => { | ||
cy.mount(TestInput, { | ||
componentProperties: { | ||
maskitoOptions: maskitoNumberOptionsGenerator({ | ||
precision: 2, | ||
minusSign: '-', | ||
}), | ||
}, | ||
}); | ||
cy.get('input').focus().should('have.value', ''); | ||
}); | ||
|
||
it('empty integer part & NOT empty decimal part => keeps decimal separator untouched', () => { | ||
cy.get('input') | ||
.type('0.12') | ||
.type('{backspace}'.repeat(2)) | ||
.should('have.value', '0.'); | ||
}); | ||
|
||
it('NOT empty integer part & empty decimal part => keeps decimal separator untouched', () => { | ||
cy.get('input') | ||
.type('0.12') | ||
.type('{moveToStart}') | ||
.type('{del}') | ||
.should('have.value', '.12'); | ||
}); | ||
|
||
describe('empty integer part & empty decimal part => drops decimal separator', () => { | ||
[ | ||
{minusSign: '', testTitle: 'Without minus'}, | ||
{minusSign: '-', testTitle: 'With minus'}, | ||
].forEach(({testTitle, minusSign}) => { | ||
it(testTitle, () => { | ||
cy.get('input') | ||
.type(`${minusSign}0.12`) | ||
.type('{backspace}'.repeat(2)) | ||
.type(`{moveToStart}${'{rightArrow}'.repeat(minusSign.length)}`) | ||
.type('{del}') | ||
.should('have.value', minusSign) | ||
// and then repeat everything in reversed order | ||
.type('0.12') | ||
.type(`{moveToStart}${'{rightArrow}'.repeat(minusSign.length)}`) | ||
.type('{del}') | ||
.type('{moveToEnd}') | ||
.type('{backspace}'.repeat(2)) | ||
.should('have.value', minusSign); | ||
}); | ||
}); | ||
}); | ||
}); |
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