Skip to content
This repository was archived by the owner on Mar 31, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add integration test case for refs that reproduces issue seen with
string refs.
  • Loading branch information
Thomas Huston committed Oct 18, 2018
commit 2d5979f00a845d77fd98f64935b698fe03e0f088
41 changes: 41 additions & 0 deletions integration-tests/react-percy/src/Refs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import PropTypes from 'prop-types';
import React from 'react';

export default class Refs extends React.Component {
static propTypes = {
children: PropTypes.string.isRequired,
type: PropTypes.oneOf(['string', 'function', 'createRef']).isRequired,
};

ref = React.createRef();

render() {
switch (this.props.type) {
case 'string':
return (
// eslint-disable-next-line react/no-string-refs
<div ref="test">
{this.props.children}
</div>
);

case 'function':
return (
<div
ref={el => {
this.el = el;
}}
>
{this.props.children}
</div>
);

case 'createRef':
return (
<div ref={this.ref}>
{this.props.children}
</div>
);
}
}
}
16 changes: 16 additions & 0 deletions integration-tests/react-percy/src/__percy__/Refs.percy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import Refs from '../Refs';

suite('Refs', () => {
percySnapshot('components with string refs work', () => {
return <Refs type="string">This is some text</Refs>;
});

percySnapshot('components with function refs work', () => {
return <Refs type="function">This is some text</Refs>;
});

percySnapshot('components using createRef work', () => {
return <Refs type="createRef">This is some text</Refs>;
});
});