We got used to make variables protected which are only used in a component and its subclasses but not in the template.
That's especially an advantage if you have like 10 many variables in your class and with protected private and public it's very easy to know which variables are used in the template.
@Input() public disablePlus: boolean = false;
@Input() public disableMinus: boolean = false;
@Input() protected jumpSize: number = 1000;
now I'm about to create some unit-test for this component. But i cannot activly change those values inside my it method:
it('should change jumpSize to 5000', () => {
component.jumpSize= 5000;
// ts2445: Property `jumpSize` is protected and only accessible within class and its subclasses
...
});
it('plus should be disabled', () => {
component.disablePlus= true; // no error
...
});
Is there a way to leave jumpSize protected or do we have to change it to public?
Or do you event think that our approach with protected @Input fields is anyway stupid and not very useful?
I'm thankful for any advice.