-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: inputs with
extends TuiControl
has CD problems for `writeValue…
…` of empty value
- Loading branch information
1 parent
b2081d7
commit f2089b5
Showing
3 changed files
with
124 additions
and
24 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
projects/demo-cypress/src/tests/input-number/write-value-empty-string.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,78 @@ | ||
import {ChangeDetectionStrategy, Component} from '@angular/core'; | ||
import {FormsModule} from '@angular/forms'; | ||
import {TuiInputNumber} from '@taiga-ui/kit'; | ||
import {TuiRoot, TuiTextfield} from '@taiga-ui/core'; | ||
|
||
describe('InputNumber | Form control is patched with empty string', () => { | ||
@Component({ | ||
standalone: true, | ||
imports: [FormsModule, TuiInputNumber, TuiRoot, TuiTextfield], | ||
template: ` | ||
<tui-root> | ||
<tui-textfield> | ||
<label tuiLabel>Label</label> | ||
<input | ||
tuiInputNumber | ||
[(ngModel)]="value" | ||
/> | ||
</tui-textfield> | ||
<br /> | ||
<button | ||
id="42" | ||
(click)="value = 42" | ||
> | ||
Click me to set "42" | ||
</button> | ||
<button | ||
id="null" | ||
(click)="value = null" | ||
> | ||
Click me to set "null" | ||
</button> | ||
</tui-root> | ||
`, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
class Test { | ||
protected value: number | null = null; | ||
} | ||
|
||
beforeEach(() => { | ||
cy.mount(Test); | ||
cy.get('[tuiInputNumber]').as('textfield'); | ||
cy.get('@textfield').type('123'); | ||
}); | ||
|
||
it('Patch value with not-empty value', () => { | ||
cy.get('#42').click(); | ||
|
||
cy.get('@textfield').should('have.value', '42'); | ||
cy.get('tui-textfield').compareSnapshot({ | ||
name: 'input-number-write-value-42', | ||
cypressScreenshotOptions: {padding: 8}, | ||
}); | ||
}); | ||
|
||
it('Patch value with empty value', () => { | ||
cy.get('#null').click(); | ||
|
||
cy.get('@textfield').should('have.value', ''); | ||
cy.get('tui-textfield').compareSnapshot({ | ||
name: 'input-number-write-value-empty-string', | ||
cypressScreenshotOptions: {padding: 8}, | ||
}); | ||
}); | ||
|
||
it('Patch not empty value after textfield was already patched with empty string', () => { | ||
cy.get('#null').click(); | ||
cy.get('#42').click(); | ||
|
||
cy.get('@textfield').should('have.value', '42'); | ||
cy.get('tui-textfield').compareSnapshot({ | ||
name: 'input-number-write-value-42-after-empty', | ||
cypressScreenshotOptions: {padding: 8}, | ||
}); | ||
}); | ||
}); |
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