I'm facing a problem when i try to test object from array if it's visibility is false I can't reach the object
Typescript code
this.currentActionEvent = event;
switch (event) {
case imp.quickAction.afterNewQuick:
case imp.quickAction.afterNewOperation:
this.afterNew({
dimmedControls: ['codeTyp', 'codeTypNm']
});
this['stpCodeDtl'].Columns.find(
(obj) => obj.field === 'codeNo'
).visible = false;
break;
case imp.quickAction.afterModifyQuick:
case imp.quickAction.afterModifyOperation:
this.afterModify({
dimmedControls: ['codeTyp', 'codeTypNm']
});
this['stpCodeDtl'].Columns.find(
(obj) => obj.field === 'codeNo'
).visible = false;
break;
}
Unit test code
it('should afterNew() been called , passed test cases', function () {
component.scrMenusEvents(quickAction.afterNewQuick);
expect(component.afterNew).toHaveBeenCalledWith({ dimmedControls: ['codeTyp', 'codeTypNm'] });
fixture.detectChanges();
expect(component['stpCodeDtl'].Columns.codeNo).toBeUndefined();
// let effctTrnsFlgField = false
// expect(fixture.debugElement.query
// (By.css(component.columns.field))).toBeUndefined();
});
it('should afterModify() been called , passed test cases', function () {
component.scrMenusEvents(quickAction.afterModifyQuick);
fixture.detectChanges();
expect(component.afterModify).toHaveBeenCalledWith({
dimmedControls: ['codeTyp', 'codeTypNm']
});
});
I tried so much i'am new with unit test and always finding a problems with this pary find function or foreach and the subscription ones too so any help please! There's spec and typescript files below. Spec File Typescript File