2024-07-23 16:50:12 +00:00
|
|
|
/*!
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright Google LLC All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
|
* found in the LICENSE file at https://angular.dev/license
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
|
|
|
|
|
|
|
|
|
import {TextField} from './text-field.component';
|
|
|
|
|
|
|
|
|
|
describe('TextField', () => {
|
|
|
|
|
let component: TextField;
|
|
|
|
|
let fixture: ComponentFixture<TextField>;
|
|
|
|
|
|
2026-01-04 04:23:19 +00:00
|
|
|
beforeEach(async () => {
|
2024-07-23 16:50:12 +00:00
|
|
|
fixture = TestBed.createComponent(TextField);
|
|
|
|
|
component = fixture.componentInstance;
|
2026-01-04 04:23:19 +00:00
|
|
|
await fixture.whenStable();
|
2024-07-23 16:50:12 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should create', () => {
|
|
|
|
|
expect(component).toBeTruthy();
|
|
|
|
|
});
|
2025-05-05 21:20:26 +00:00
|
|
|
|
2026-01-04 04:23:19 +00:00
|
|
|
it('should update DOM when setting the value via the CVA', async () => {
|
2025-05-05 21:20:26 +00:00
|
|
|
component.setValue('test');
|
2026-01-04 04:23:19 +00:00
|
|
|
await fixture.whenStable();
|
2025-05-05 21:20:26 +00:00
|
|
|
|
|
|
|
|
expect(fixture.nativeElement.querySelector('input').value).toBe('test');
|
|
|
|
|
// If we were using ngModel instead of the value binding, we would get an empty string
|
|
|
|
|
// because of https://github.com/angular/angular/issues/13568
|
|
|
|
|
});
|
2024-07-23 16:50:12 +00:00
|
|
|
});
|