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

Allow promise to be returned from 'add()' #1670

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a0647e4
Allow promise to be returned from 'add()'
dchambers Aug 17, 2017
184fd60
Merge branch 'master' into master
dchambers Aug 17, 2017
4bf6f8b
Merge branch 'master' into master
ndelangen Aug 18, 2017
c70fa3f
Merge branch 'master' into master
ndelangen Aug 18, 2017
b4b9ae8
Merge branch 'master' into master
Hypnosphi Aug 22, 2017
9d540aa
Merge branch 'master' into master
ndelangen Aug 22, 2017
ed514ef
Merge branch 'master' into master
dchambers Aug 22, 2017
02b307a
Document ability to wrap stories in promises
dchambers Aug 22, 2017
e06f2a9
Merge branch 'release/3.3' into master
ndelangen Aug 25, 2017
af0a7b6
Merge branch 'release/3.3' into master
ndelangen Sep 6, 2017
b7f2ed2
Merge branch 'release/3.3' into master
Hypnosphi Sep 6, 2017
1de3f22
Create CRA app for ES6-Promise kitchen sink
dchambers Sep 7, 2017
c94e1ec
Add Storybook to kitchen-sink
dchambers Sep 7, 2017
4dae5b5
Use storyshots to test the stories
dchambers Sep 7, 2017
b3e51bf
Make the `README.md` relevant for the kitchen-sink
dchambers Sep 7, 2017
49203b4
Wrap stories in promises
dchambers Sep 7, 2017
3ae6f4d
Update kitchen-sink to test code in this repo
dchambers Sep 7, 2017
52bbdaa
Merge branch 'release/3.3' into master
ndelangen Sep 7, 2017
220c2dc
Merge branch 'release/3.3' into master
Hypnosphi Sep 7, 2017
eb40517
Merge branch 'release/3.3' into master
ndelangen Sep 8, 2017
3fec2f4
ADD support for async components + decorators && ADD async render to …
ndelangen Sep 8, 2017
4fa1f0a
FIX documentation & CORRECT usage of async story
ndelangen Sep 8, 2017
eb658f1
DELETE redundant example
ndelangen Sep 8, 2017
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
2 changes: 1 addition & 1 deletion addons/storyshots/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default function testStorySnapshots(options = {}) {

it(story.name, () => {
const context = { kind: group.kind, story: story.name };
options.test({ story, context });
return options.test({ story, context });
});
}
});
Expand Down
10 changes: 5 additions & 5 deletions addons/storyshots/src/test-bodies.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import renderer from 'react-test-renderer';
import shallow from 'react-test-renderer/shallow';

export const snapshotWithOptions = options => ({ story, context }) => {
const storyElement = story.render(context);
const tree = renderer.create(storyElement, options).toJSON();
expect(tree).toMatchSnapshot();
};
export const snapshotWithOptions = options => ({ story, context }) =>
Promise.resolve(story).then(storyVal => storyVal.render(context)).then(storyElement => {
const tree = renderer.create(storyElement, options).toJSON();
expect(tree).toMatchSnapshot();
});

export const snapshot = snapshotWithOptions({});

Expand Down
52 changes: 26 additions & 26 deletions app/react/src/client/preview/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,32 +71,32 @@ export function renderMain(data, storyStore) {
story: selectedStory,
};

const element = story(context);

if (!element) {
const error = {
title: `Expecting a React element from the story: "${selectedStory}" of "${selectedKind}".`,
description: stripIndents`
Did you forget to return the React element from the story?
Use "() => (<MyComp/>)" or "() => { return <MyComp/>; }" when defining the story.
`,
};
return renderError(error);
}

if (!isReactRenderable(element)) {
const error = {
title: `Expecting a valid React element from the story: "${selectedStory}" of "${selectedKind}".`,
description: stripIndents`
Seems like you are not returning a correct React element from the story.
Could you double check that?
`,
};
return renderError(error);
}

ReactDOM.render(element, rootEl);
return null;
return Promise.resolve(story(context)).then(element => {
if (!element) {
const error = {
title: `Expecting a React element from the story: "${selectedStory}" of "${selectedKind}".`,
description: stripIndents`
Did you forget to return the React element from the story?
Use "() => (<MyComp/>)" or "() => { return <MyComp/>; }" when defining the story.
`,
};
return renderError(error);
}

if (!isReactRenderable(element)) {
const error = {
title: `Expecting a valid React element from the story: "${selectedStory}" of "${selectedKind}".`,
description: stripIndents`
Seems like you are not returning a correct React element from the story.
Could you double check that?
`,
};
return renderError(error);
}

ReactDOM.render(element, rootEl);
return null;
});
}

export default function renderPreview({ reduxStore, storyStore }) {
Expand Down