From b70cf7eb47eb8b0879a194fde0924b825640bb44 Mon Sep 17 00:00:00 2001 From: Michael Small Date: Sun, 15 Sep 2024 12:13:52 -0500 Subject: [PATCH] test(form-events): refer to right observable vs signal cases, add obs case While I was making a test for fixing Issue #491: Handle getting value from disabled form controls in form-events util, I realized the tests were misphrased, in that they didn't handle exactly what was said. --- .../form-events/src/form-events.spec.ts | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/libs/ngxtension/form-events/src/form-events.spec.ts b/libs/ngxtension/form-events/src/form-events.spec.ts index 4ffd9f39..fb4d0d3e 100644 --- a/libs/ngxtension/form-events/src/form-events.spec.ts +++ b/libs/ngxtension/form-events/src/form-events.spec.ts @@ -115,7 +115,7 @@ describe('Form Events', () => { ); }); - it('returns a signal with the value, status, pristine, and touched values of a form after it has been interacted with', async () => { + it('returns an observable with the value, status, pristine, and touched values of a form after it has been interacted with', async () => { const fixture: ComponentFixture = TestBed.configureTestingModule({ imports: [FormEventsComponent], @@ -165,10 +165,30 @@ describe('Form Events', () => { fixture.detectChanges(); - const signalVals: HTMLElement = fixture.debugElement.query( + const observableVals: HTMLElement = fixture.debugElement.query( By.css('[data-testid="observable-values-initial-value-overwritten"]'), ).nativeElement; + expect(flattenJsonPipeFormatting(observableVals.textContent)).toBe( + flattenJsonPipeFormatting(`{ + "value": { + "name": "custom" + }, + "status": "VALID", + "touched": false, + "pristine": true, + "valid": true, + "invalid": false, + "pending": false, + "dirty": false, + "untouched": true + }`), + ); + + const signalVals: HTMLElement = fixture.debugElement.query( + By.css('[data-testid="signal-values-initial-value-overwritten"]'), + ).nativeElement; + expect(flattenJsonPipeFormatting(signalVals.textContent)).toBe( flattenJsonPipeFormatting(`{ "value": {