generated from Tinkoff/angular-open-source-starter
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
120 additions
and
31 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
26 changes: 0 additions & 26 deletions
26
projects/demo-integrations/cypress/tests/angular/di-approach.cy.ts
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
projects/demo-integrations/cypress/tests/angular/predicate.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,16 @@ | ||
import {DemoPath} from '@demo/path'; | ||
|
||
describe('@maskito/angular | Predicate', () => { | ||
it('can detect run-time changes', () => { | ||
cy.visit(`/${DemoPath.Cypress}`); | ||
cy.get('#predicate input').should('be.visible').first().as('card'); | ||
cy.get('#predicate input').should('be.visible').last().as('name'); | ||
|
||
cy.get('@card') | ||
.focus() | ||
.type('12341234abcd12341234') | ||
.should('have.value', '1234 1234 1234 1234'); | ||
|
||
cy.get('@name').focus().type('12341234abcd12341234').should('have.value', 'ABCD'); | ||
}); | ||
}); |
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,8 @@ | ||
import {ChangeDetectionStrategy, Component} from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'cypress-doc-page', | ||
templateUrl: './cypress.template.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class CypressDocPageComponent {} |
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,26 @@ | ||
import {CommonModule} from '@angular/common'; | ||
import {NgModule} from '@angular/core'; | ||
import {FormsModule} from '@angular/forms'; | ||
import {RouterModule} from '@angular/router'; | ||
import {MaskitoModule} from '@maskito/angular'; | ||
import {TuiAddonDocModule, tuiGenerateRoutes} from '@taiga-ui/addon-doc'; | ||
import {TuiGroupModule} from '@taiga-ui/core'; | ||
import {TuiInputModule} from '@taiga-ui/kit'; | ||
|
||
import {CypressDocPageComponent} from './cypress.component'; | ||
import {TestDocExample1} from './examples/1-predicate/component'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
FormsModule, | ||
MaskitoModule, | ||
TuiInputModule, | ||
TuiGroupModule, | ||
TuiAddonDocModule, | ||
RouterModule.forChild(tuiGenerateRoutes(CypressDocPageComponent)), | ||
], | ||
declarations: [CypressDocPageComponent, TestDocExample1], | ||
exports: [CypressDocPageComponent], | ||
}) | ||
export class CypressDocPageModule {} |
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 @@ | ||
<tui-doc-page header="Cypress"> | ||
<ng-template pageTab="Tests"> | ||
<test-doc-example-1 id="predicate"></test-doc-example-1> | ||
</ng-template> | ||
</tui-doc-page> |
38 changes: 38 additions & 0 deletions
38
projects/demo/src/pages/cypress/examples/1-predicate/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,38 @@ | ||
import {ChangeDetectionStrategy, Component} from '@angular/core'; | ||
import {MaskitoPredicate} from '@maskito/angular'; | ||
import {MaskitoOptions} from '@maskito/core'; | ||
|
||
@Component({ | ||
selector: 'test-doc-example-1', | ||
templateUrl: './template.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class TestDocExample1 { | ||
value = { | ||
number: '', | ||
name: '', | ||
}; | ||
|
||
readonly cardMask: MaskitoOptions = { | ||
mask: [ | ||
...Array(4).fill(/\d/), | ||
' ', | ||
...Array(4).fill(/\d/), | ||
' ', | ||
...Array(4).fill(/\d/), | ||
' ', | ||
...Array(4).fill(/\d/), | ||
], | ||
}; | ||
|
||
readonly nameMask: MaskitoOptions = { | ||
mask: /^[a-zA-Z\s]+$/, | ||
postprocessor: ({value, selection}) => ({value: value.toUpperCase(), selection}), | ||
}; | ||
|
||
readonly cardPredicate: MaskitoPredicate = element => | ||
element.querySelectorAll('input')[0]!; | ||
|
||
readonly namePredicate: MaskitoPredicate = element => | ||
element.querySelectorAll('input')[1]!; | ||
} |
13 changes: 13 additions & 0 deletions
13
projects/demo/src/pages/cypress/examples/1-predicate/template.html
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 @@ | ||
<div | ||
tuiGroup | ||
[maskito]="card.focused ? cardMask : nameMask" | ||
[maskitoElement]="card.focused ? cardPredicate : namePredicate" | ||
> | ||
<tui-input | ||
#card | ||
[(ngModel)]="value.number" | ||
> | ||
Card number | ||
</tui-input> | ||
<tui-input [(ngModel)]="value.name">Name</tui-input> | ||
</div> |
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