-
-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Figure out a way to test a mocked structural directives input #36
Comments
Maybe throw something on the directive host? |
Hey @satanTime I've been messing around with this trying to come up with a solution and nothing I've tried has worked out for me. Do you happen to have any ideas on how this could be accomplished? |
Hi. Very good question. I've never written any structural directive. But if it's true as docs explain: https://angular.io/guide/structural-directives#inside-ngfor (they're syntax sugar), I think your library already has almost everything, except a way to pass The same thing I use in some my templates with Once we have way to control |
It does have support for structural directives but the problem is that these directives aren't available on the host element's injector, unlike normal attribute directives. This makes getting the directive back out of the debug element in the test to assert on inputs challenging (if possible). At this point I'd settle with throwing a data attribute on the host with the directive name and inputs but I had issues with that as well. 🤷🏻♂️ |
Aha :) good to know. Let me dive inside one day to check how it works. Is there any branch where I could check what you'd tried before? |
☣ |
Hi @ike18t, how do you do? Might you review possible solution? #40 |
I've implemented helper function which works together with attribute and structural directives: // Extracting mock.
const debugElement = fixture.debugElement.query(By.css('div'));
const directive = MockHelper.getDirective(
debugElement,
MockDirective(CustomNgIfDirective),
);
expect(directive).toBeTruthy();
if (!directive) {
return;
} |
No description provided.
The text was updated successfully, but these errors were encountered: