Last active
December 11, 2015 13:10
-
-
Save vslinko/1c427a055e1188d2245a to your computer and use it in GitHub Desktop.
React Markers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function marker(value) { | |
if (process.env.NODE_ENV !== 'production') { | |
return { | |
'data-marker': value, | |
}; | |
} | |
return {}; | |
} | |
export function createMarker(prefix) { | |
return (suffix) => marker(`${prefix}-${suffix}`); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mark = createMarker('Logo'); | |
export default class Logo extends React.Component { | |
render() { | |
return ( | |
<Link | |
{...mark('Link')} | |
/> | |
); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function marker(value) { | |
return `[data-marker="${value}"]`; | |
} | |
export function createMarker(prefix) { | |
return (suffix) => marker(`${prefix}-${suffix}`); | |
} | |
export function chain(...selectors) { | |
return selectors.join(' '); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('logo/isLink', async (t) => { | |
const b = createHeadlessBrowser(); | |
await b.openUrl('/'); | |
await b.waitForSelector(Logo('Link')); | |
const logo = b.querySelector(Logo('Link')); | |
t.equal(logo.tagName, 'A'); | |
t.equal(logo.getAttribute('href'), '/'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment