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

test(refs): added tests for ref utility #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

itaditya
Copy link

@itaditya itaditya commented Nov 9, 2019

fix #45

@s-yadav
Copy link
Collaborator

s-yadav commented Nov 10, 2019

The specs are testing the internal utilities here. What about using the refs with actual components, dom elements and testing if we are getting expected values on ref are not.

@s-yadav
Copy link
Collaborator

s-yadav commented Nov 10, 2019

We probably can reuse the specs from React.
https://github.com/facebook/react/tree/master/packages/react/src/__tests__

You can also check for Preact specs.

});
});

it('should set instance as current when setRef called with object type ref', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setRef is inner API we should do integration test of it. Similar to what you did for forwardRefs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

expect(ref.current).toBe('instance');
});

it('should pass instance as param when setRef called with function type ref', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^^

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 this pull request may close these issues.

Tests for Refs API
2 participants