generated from Tinkoff/angular-open-source-starter
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(kit):
Prefix
/Postfix
is incompatible if they end/start with t…
…he same character (#366)
- Loading branch information
1 parent
501cf9c
commit 06afbcb
Showing
11 changed files
with
360 additions
and
157 deletions.
There are no files selected for viewing
378 changes: 234 additions & 144 deletions
378
projects/demo-integrations/cypress/tests/kit/number/number-prefix-postfix.cy.ts
Large diffs are not rendered by default.
Oops, something went wrong.
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,5 @@ | ||
.tests-wrapper { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 3rem; | ||
} |
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 |
---|---|---|
@@ -1,7 +1,13 @@ | ||
<tui-doc-page header="Cypress"> | ||
<ng-template pageTab="Tests"> | ||
<test-doc-example-1 id="predicate"></test-doc-example-1> | ||
<div class="tests-wrapper"> | ||
<test-doc-example-1 id="predicate"></test-doc-example-1> | ||
|
||
<test-doc-example-2 id="maxlength"></test-doc-example-2> | ||
<test-doc-example-2 id="maxlength"></test-doc-example-2> | ||
|
||
<test-doc-example-3 | ||
id="mirrored-prefix-postfix" | ||
></test-doc-example-3> | ||
</div> | ||
</ng-template> | ||
</tui-doc-page> |
20 changes: 20 additions & 0 deletions
20
projects/demo/src/pages/cypress/examples/3-mirrored-prefix-postfix/component.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,20 @@ | ||
import {ChangeDetectionStrategy, Component} from '@angular/core'; | ||
import {MaskitoOptions} from '@maskito/core'; | ||
import {maskitoNumberOptionsGenerator} from '@maskito/kit'; | ||
|
||
@Component({ | ||
selector: 'test-doc-example-3', | ||
template: ` | ||
<input | ||
value="$ 100 per day" | ||
[maskito]="numberMask" | ||
/> | ||
`, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class TestDocExample3 { | ||
readonly numberMask: MaskitoOptions = maskitoNumberOptionsGenerator({ | ||
prefix: '$ ', | ||
postfix: ' per day', | ||
}); | ||
} |
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
13 changes: 13 additions & 0 deletions
13
projects/kit/src/lib/utils/find-common-beginning-substr.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,13 @@ | ||
export function findCommonBeginningSubstr(a: string, b: string): string { | ||
let res = ''; | ||
|
||
for (let i = 0; i < a.length; i++) { | ||
if (a[i] !== b[i]) { | ||
return res; | ||
} | ||
|
||
res += a[i]; | ||
} | ||
|
||
return res; | ||
} |
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
20 changes: 20 additions & 0 deletions
20
projects/kit/src/lib/utils/tests/find-common-beginning-substr.spec.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,20 @@ | ||
import {findCommonBeginningSubstr} from '../find-common-beginning-substr'; | ||
|
||
describe('findCommonBeginningSubstr', () => { | ||
it('returns common substring until all characters are equal', () => { | ||
expect(findCommonBeginningSubstr('123_456', '123456')).toBe('123'); | ||
}); | ||
|
||
it('returns empty string if any string is empty', () => { | ||
expect(findCommonBeginningSubstr('123_456', '')).toBe(''); | ||
expect(findCommonBeginningSubstr('', '123_456')).toBe(''); | ||
}); | ||
|
||
it('returns empty string if the first characters are different', () => { | ||
expect(findCommonBeginningSubstr('012345', '123')).toBe(''); | ||
}); | ||
|
||
it('returns the whole string if all characters are equal', () => { | ||
expect(findCommonBeginningSubstr('777999', '777999')).toBe('777999'); | ||
}); | ||
}); |