Skip to content

Commit

Permalink
Merge pull request #57 from storybooks/tests
Browse files Browse the repository at this point in the history
Add Fragment Tests
  • Loading branch information
hipstersmoothie authored Mar 18, 2019
2 parents d31b835 + 5612bed commit cb016de
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 3 deletions.
6 changes: 3 additions & 3 deletions example/stories/decorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Simple = props => (

storiesOf('Decorator', module)
.addDecorator(jsxDecorator)
.addWithJSX(
.add(
'Simple Array',
() => (
<div>
Expand All @@ -22,7 +22,7 @@ storiesOf('Decorator', module)
),
{ skip: 1 }
)
.addWithJSX(
.add(
'Array with function',
() => (
<div>
Expand All @@ -33,7 +33,7 @@ storiesOf('Decorator', module)
),
{ skip: 1 }
)
.addWithJSX(
.add(
'Array with nested component',
() => (
<div>
Expand Down
27 changes: 27 additions & 0 deletions example/stories/fragments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { jsxDecorator } from '../../lib/index';

const Component = () => <div />;
const Simple = props => (
<div>
<span>Hello</span>
{props.children}
</div>
);

storiesOf('Fragments', module)
.addDecorator(jsxDecorator)
.add('Simple Fragment', () => (
<React.Fragment>
<div />
<div />
</React.Fragment>
))
.add('Array', () => [<div key="1" />, <div key="2" />])
.add('Fragment Shorthand', () => (
<>
<div />
<div />
</>
));
1 change: 1 addition & 0 deletions example/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import './simple';
import './deep';
import './decorator';
import './functions';
import './fragments';
import './array';
import './withProps';
21 changes: 21 additions & 0 deletions src/__tests__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,27 @@ exports[`Storyshots Deep Test With children - Skip and rename 1`] = `
</div>
`;

exports[`Storyshots Fragments Array 1`] = `
Array [
<div />,
<div />,
]
`;

exports[`Storyshots Fragments Fragment Shorthand 1`] = `
Array [
<div />,
<div />,
]
`;

exports[`Storyshots Fragments Simple Fragment 1`] = `
Array [
<div />,
<div />,
]
`;

exports[`Storyshots Function as a children Deep function - No options 1`] = `
<div>
<div>
Expand Down

0 comments on commit cb016de

Please sign in to comment.