Skip to content

Commit

Permalink
chore: increase test coverage of BaseInputValueAccessor
Browse files Browse the repository at this point in the history
  • Loading branch information
ersimont committed Jun 22, 2019
1 parent b1766b2 commit 5b286e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
async,
ComponentFixture,
fakeAsync,
flushMicrotasks,
TestBed,
tick,
} from "@angular/core/testing";
Expand Down Expand Up @@ -671,19 +672,23 @@ describe("nasModel", () => {
}));

it("can control disabledness", fakeAsync(() => {
const store = initTest(NameComponent, NameStore, {
extraDirectives: [InnerNameComponent],
});
store.assign({ isDisabled: true });
const store = initSingleValueTest(`
<input
type="number"
[nasModel]="store('num')"
[disabled]="store('disabled').$ | async"
/>
`);
store.set({ num: 2, disabled: true });
const input = query("input");

detectChanges();
tick(0);
flushMicrotasks();
expect(input.disabled).toBe(true);

store.assign({ isDisabled: false });
store.assign({ disabled: false });
detectChanges();
tick(0);
flushMicrotasks();
expect(input.disabled).toBe(false);
}));
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export abstract class BaseInputValueAccessor extends BaseValueAccessor<
this.element.value = value;
}

setDisabledState(isDisabled: boolean): void {
setDisabledState(isDisabled: boolean) {
this.element.disabled = isDisabled;
}
}

0 comments on commit 5b286e6

Please sign in to comment.