Hi there, I just cant get this right. Been stuck testing a view.Encapsulated component (micro frontend) which just made my life hell today. So I am now testing without that. Shadow dom just makes it harder. So now testing as normal. I have manage to test many thing but what I cant get right is to test if a form is visible.
I think if someone can help me, it will push me in the right direction.
I have this as a simple explanation of what I am doing. I have an ngOnInit which fires connectForm function (these are fired off at least once)
Now when connectForm is fired, I do a http request to see if data is good. Then if its good, i need to show the form. How do I test that the form is visible once I have done a fake request?
Angular code is below
isConnected(response){
this.showForm = true;
}
connectForm(dataToBeSent){
const url = `${this.apiUrl}/verify-form`;
const headers = new HttpHeaders({
'Content-Type': 'application/json'
});
this.http.post(url, dataToBeSent, { headers })
.subscribe(
{
next: (response) => {
this.isConnected(response);
},
error: (err: any) => {
this.cantConnect(err);
},
complete: () => { }
}
);
}
ngOnInit() {
this.connectForm({data: data})
}