0

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

Omar Khaled
  • 77
  • 2
  • 10
  • Hi Omar, Please confirm the exact Syncfusion components along with platform EJ1 or EJ2 for which you require to include the test case so that we can proceed further. – keerthana Dec 08 '21 at 10:13
  • project has an app-grid component that redering the columns and rows of datasource in syncfusion so you need that component or the version of syncfusion? – Omar Khaled Dec 08 '21 at 11:15

0 Answers0