From bd2351fc782b263a8bc0443d5ee0344da14dcf4d Mon Sep 17 00:00:00 2001 From: John Rodriguez Date: Wed, 25 Jan 2017 17:58:51 -0500 Subject: [PATCH] Allow passing options to react-test-renderer .create() method --- src/index.js | 2 +- .../__snapshots__/storyshots.test.js.snap | 17 +++++++++ stories/__test__/storyshots.test.js | 10 +++++- .../required_with_context/ComponentWithRef.js | 36 +++++++++++++++++++ .../ComponentWithRef.stories.js | 8 +++++ 5 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 stories/required_with_context/ComponentWithRef.js create mode 100644 stories/required_with_context/ComponentWithRef.stories.js diff --git a/src/index.js b/src/index.js index fd8021d..1952458 100644 --- a/src/index.js +++ b/src/index.js @@ -62,7 +62,7 @@ export default function testStorySnapshots (options = {}) { it(story.name, () => { const context = { kind: group.kind, story: story.name } const renderedStory = story.render(context) - const tree = renderer.create(renderedStory).toJSON() + const tree = renderer.create(renderedStory, options.rendererOptions).toJSON() expect(tree).toMatchSnapshot() }) } diff --git a/stories/__test__/__snapshots__/storyshots.test.js.snap b/stories/__test__/__snapshots__/storyshots.test.js.snap index c02481b..66bb94f 100644 --- a/stories/__test__/__snapshots__/storyshots.test.js.snap +++ b/stories/__test__/__snapshots__/storyshots.test.js.snap @@ -70,6 +70,23 @@ exports[`Storyshots Button with text 1`] = ` `; +exports[`Storyshots Component with ref on mount 1`] = ` + +`; + exports[`Storyshots Welcome to Storybook 1`] = `
this.setRef(r)} + style={inputStyles} + /> + ) + } +} + +ComponentWithRef.propTypes = { + onLoad: React.PropTypes.func +} + +export default ComponentWithRef diff --git a/stories/required_with_context/ComponentWithRef.stories.js b/stories/required_with_context/ComponentWithRef.stories.js new file mode 100644 index 0000000..50ec6b0 --- /dev/null +++ b/stories/required_with_context/ComponentWithRef.stories.js @@ -0,0 +1,8 @@ +import React from 'react' +import { storiesOf, action } from '@kadira/storybook' +import ComponentWithRef from './ComponentWithRef' + +storiesOf('Component with ref', module) + .add('on mount', () => ( + + ))