Skip to content

Commit

Permalink
test(form-events): refer to right observable vs signal cases, add obs…
Browse files Browse the repository at this point in the history
… case

While I was making a test for fixing Issue ngxtension#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.
  • Loading branch information
michael-small authored and msmallest committed Nov 1, 2024
1 parent b1f27db commit 04a8e4b
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions libs/ngxtension/form-events/src/form-events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<FormEventsComponent> =
TestBed.configureTestingModule({
imports: [FormEventsComponent],
Expand Down Expand Up @@ -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": {
Expand Down

0 comments on commit 04a8e4b

Please sign in to comment.