You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a component we provide two inputs, avatar and name. Whenever avatar is undefined and a name is given, it should render the initials instead of an image. To test this behaviour we've used rerender:
rerender({avatar: 'https://clipground.com/images/img_avatar-png-2.png'});constrenderedAvatar=screen.getByRole('img');expect(renderedAvatar).toBeInTheDocument();expect(renderedAvatar).toHaveAttribute('src','https://clipground.com/images/img_avatar-png-2.png');
...
rerender({name: 'John Appleseed'});// Initials should only exist if `avatar` is `undefined`constrenderedInitials=screen.getByText(/J/);(renderedInitials).toBeInTheDocument();
renderedAvatar succeeds as expected, but renderedInitials fails since avatar is still set – while I expected passing an object to rerender would completely replace all props.
The test succeeds when I explicitly set avatar:
rerender({avatar: undefined,name: 'John Appleseed'});// Initials should only exist if `avatar` is `undefined`constrenderedInitials=screen.getByText(/J/);(renderedInitials).toBeInTheDocument();
The text was updated successfully, but these errors were encountered:
Thanks for opening this issue @MysticEarth.
It seems like the other TL libraries are expecting like this, so we'll have to change our behavior.
The reason why it behaves like this, is to be able to test ngOnChange - which I think is valuable,
Because of this, I think the current render method should be renamed to change or update or something like that...
It would require a breaking change, so it could be a while before this lands.
Maybe with Angular v13...
In a component we provide two inputs,
avatar
andname
. Wheneveravatar
isundefined
and aname
is given, it should render the initials instead of an image. To test this behaviour we've usedrerender
:renderedAvatar
succeeds as expected, butrenderedInitials
fails sinceavatar
is still set – while I expected passing an object torerender
would completely replace all props.The test succeeds when I explicitly set
avatar
:The text was updated successfully, but these errors were encountered: