How i can test this in angular?
get isPerson() {
return this.persons.some((person) => person === this.personId);
}
I was trying something like this without sucsess:
it('should get person', () => {
const person = new Person('John', 'Doe');
const spy = spyOnProperty(person, 'isPerson').and.returnValue(
'john doe'
);
expect(person.fullName).toBe('john doe');
expect(spy).toHaveBeenCalled();
});
CodePudding user response:
If you are testing a component, do this
it('should get person', () => {
const person = new Person('John', 'Doe');
component.person = person
component.personId = 'John'
fixture.detectChanges()
expect(component.isPerson).toBeTruthy()
});