Skip to content
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

Add support for mocking inherited members #69

Closed
rmcc13 opened this issue Dec 17, 2019 · 2 comments · Fixed by #94
Closed

Add support for mocking inherited members #69

rmcc13 opened this issue Dec 17, 2019 · 2 comments · Fixed by #94
Assignees

Comments

@rmcc13
Copy link

rmcc13 commented Dec 17, 2019

It looks like the MockComponent method does not setup methods from inherited methods. The code for setting up mock methods for both MockDirective and MockComponent only gets methods from the class's prototype but doesn't traverse up the prototype chain to handle inheritance.

For example, Angular Material's MatSidenav component extends the MatDrawer component and methods defined on MatDrawer are not setup when mocking MatSidenav. This can cause some confusion when some methods on a type are setup and others are not.

Here's a small stackblitz that reproduces the error

@ike18t
Copy link
Collaborator

ike18t commented Jan 23, 2020

Neither MockComponent or MockDirective have any methods from the class's prototype. The mocked entities consist of strictly inputs & outputs. If you need further implementation detail in your mock then in your test you can query for the mocked entity and extend the instance using either a mocking framework or by plain old assignment.

@satanTime satanTime self-assigned this Mar 1, 2020
@satanTime satanTime linked a pull request Mar 9, 2020 that will close this issue
@satanTime satanTime linked a pull request Mar 12, 2020 that will close this issue
@satanTime
Copy link
Member

satanTime commented Mar 12, 2020

Hi @rmcc13, could you check if the related PR works for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants