generated from Tinkoff/angular-open-source-starter
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(kit): Number
incorrectly shift caret for 1st time insertion into textfield with initial value
#1792
Merged
Merged
fix(kit): Number
incorrectly shift caret for 1st time insertion into textfield with initial value
#1792
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,56 +6,78 @@ import {TestInput} from '../utils'; | |
describe('Number | With initial value', () => { | ||
let maskitoOptions!: MaskitoOptions; | ||
|
||
beforeEach(() => { | ||
const prefix = '$'; | ||
const postfix = ' kg'; | ||
|
||
const numberOptions = maskitoNumberOptionsGenerator({ | ||
prefix, | ||
postfix, | ||
thousandSeparator: ' ', | ||
describe('with prefix & postfix', () => { | ||
beforeEach(() => { | ||
const prefix = '$'; | ||
const postfix = ' kg'; | ||
|
||
const numberOptions = maskitoNumberOptionsGenerator({ | ||
prefix, | ||
postfix, | ||
thousandSeparator: ' ', | ||
}); | ||
|
||
maskitoOptions = { | ||
...numberOptions, | ||
plugins: [ | ||
...numberOptions.plugins, | ||
maskitoCaretGuard((value) => [ | ||
prefix.length, | ||
value.length - postfix.length, | ||
]), | ||
], | ||
}; | ||
}); | ||
|
||
maskitoOptions = { | ||
...numberOptions, | ||
plugins: [ | ||
...numberOptions.plugins, | ||
maskitoCaretGuard((value) => [ | ||
prefix.length, | ||
value.length - postfix.length, | ||
]), | ||
], | ||
}; | ||
}); | ||
it('$6 432 kg => Select all + Backspace => $| kg', () => { | ||
cy.mount(TestInput, { | ||
componentProperties: {maskitoOptions, initialValue: '$6 432 kg'}, | ||
}); | ||
|
||
it('$6 432 kg => Select all + Backspace => $| kg', () => { | ||
cy.mount(TestInput, { | ||
componentProperties: {maskitoOptions, initialValue: '$6 432 kg'}, | ||
cy.get('input') | ||
.type('{selectAll}{backspace}') | ||
.should('have.value', '$ kg') | ||
.should('have.prop', 'selectionStart', 1) | ||
.should('have.prop', 'selectionEnd', 1); | ||
}); | ||
|
||
cy.get('input') | ||
.type('{selectAll}{backspace}') | ||
.should('have.value', '$ kg') | ||
.should('have.prop', 'selectionStart', 1) | ||
.should('have.prop', 'selectionEnd', 1); | ||
it('$6 4|32 kg => Delete => $64|2 kg', () => { | ||
cy.mount(TestInput, { | ||
componentProperties: {maskitoOptions, initialValue: '$6 432 kg'}, | ||
}); | ||
|
||
cy.get('input') | ||
.focus() | ||
.type('{moveToEnd}') | ||
.should('have.prop', 'selectionStart', '$6 432'.length) | ||
.should('have.prop', 'selectionEnd', '$6 432'.length) | ||
.type('{leftArrow}'.repeat(2)) | ||
.should('have.prop', 'selectionStart', '$6 4'.length) | ||
.should('have.prop', 'selectionEnd', '$6 4'.length) | ||
.type('{del}') | ||
.should('have.value', '$642 kg') | ||
.should('have.prop', 'selectionStart', '$64'.length) | ||
.should('have.prop', 'selectionEnd', '$64'.length); | ||
}); | ||
}); | ||
|
||
it('$6 4|32 kg => Delete => $64|2 kg', () => { | ||
it('123 45|6 789 => Type 0 (the 1st time input event) => 1 234 50|6 789', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New test starts here |
||
cy.mount(TestInput, { | ||
componentProperties: {maskitoOptions, initialValue: '$6 432 kg'}, | ||
componentProperties: { | ||
maskitoOptions: maskitoNumberOptionsGenerator({ | ||
thousandSeparator: ' ', | ||
}), | ||
initialValue: '123 456 789', | ||
}, | ||
}); | ||
|
||
cy.get('input') | ||
.focus() | ||
.type('{moveToEnd}') | ||
.should('have.prop', 'selectionStart', '$6 432'.length) | ||
.should('have.prop', 'selectionEnd', '$6 432'.length) | ||
.type('{leftArrow}'.repeat(2)) | ||
.should('have.prop', 'selectionStart', '$6 4'.length) | ||
.should('have.prop', 'selectionEnd', '$6 4'.length) | ||
.type('{del}') | ||
.should('have.value', '$642 kg') | ||
.should('have.prop', 'selectionStart', '$64'.length) | ||
.should('have.prop', 'selectionEnd', '$64'.length); | ||
.type('{moveToStart}') | ||
.type('{rightArrow}'.repeat('123 45'.length)) | ||
.type('0') | ||
.should('have.value', '1 234 506 789') | ||
.should('have.prop', 'selectionStart', '1 234 50'.length) | ||
.should('have.prop', 'selectionEnd', '1 234 50'.length); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -188,11 +188,12 @@ describe('Number | Zero integer part', () => { | |
|
||
cy.get('@input') | ||
.type('0,0005') | ||
.type('{moveToStart}{rightArrow}{rightArrow}') | ||
.type('{moveToStart}') | ||
.type('{rightArrow}'.repeat('0,'.length)) | ||
.type('{backspace}') | ||
.should('have.value', '00_005') | ||
.should('have.prop', 'selectionStart', '00'.length) | ||
.should('have.prop', 'selectionEnd', '00'.length) | ||
.should('have.prop', 'selectionStart', '0'.length) | ||
.should('have.prop', 'selectionEnd', '0'.length) | ||
Comment on lines
-194
to
+196
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was invalid assertion |
||
.blur() | ||
.should('have.value', '5'); | ||
}); | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests inside this
describe
were not changed (just a new tabulation)