Flag(a) {
let element=this.selected.filter(item => item.a=== a)
return element.length > 1 ? true : false;
}
Not sure how to write a unit test case for the above function. Can you please help
Flag(a) {
let element=this.selected.filter(item => item.a=== a)
return element.length > 1 ? true : false;
}
Not sure how to write a unit test case for the above function. Can you please help
Srikar Phani Kumar M
On
This should be pretty easy:
it('should run #Flag(a) method', () => {
component.selected = [{ someKey1: 'someValue1' }, { someKey2: 'someValue2' }];
const val = 'someValue1';
spyOn(component, 'Flag').and.callThrough();
component.Flag(val);
expect(component.Flag).toHaveBeenCalled();
})
Copyright © 2021 Jogjafile Inc.
A test case consists always of 3 steps:
In your case this means:
this.selected