Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
708 views
in Technique[技术] by (71.8m points)

angular - Unit test case for nativeElement focus

I need help to fix unit test cases in angular I have function to set focus on button element and this function is called in ngOnInit below is the code

public buttonElement: ElementRef,
private changeDector: ChangeDetectorRef,

above two line of code in constructor

setTimeout(() => {

    if (this.buttonElement.nativeElement.querySelectorAll('button')[0]) {
      this.buttonElement.nativeElement.querySelectorAll('button')[0].focus();
    }
}, 500);

this.changeDector.detectChanges();

I need to cover this function in unit test case .

question from:https://stackoverflow.com/questions/65919798/unit-test-case-for-nativeelement-focus

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...