Wednesday, February 12, 2020

Trigger ngOnChanges on an Angular 8 component within a Jasmine/Karma test!

beforeEach(() => {
   fixture = TestBed.createComponent(GridComponent);
   component = fixture.componentInstance;
   component.contents = {
      columns: [
         { name: "Id" },
         { name: "FullName" },
         { name: "CityState" }
      ],
      data:[ { "Id": "1", "FullName": "Ty Ng", "CityState": "NY, NY" }],
      uniqueId: 1
   };
   component.ngOnChanges({
      contents: new SimpleChange(null, "contents", true)
   });
   fixture.detectChanges();
});

No comments:

Post a Comment