Skip to content

Commit

Permalink
Add addon-jest to examples/cra-kitchen-sink
Browse files Browse the repository at this point in the history
  • Loading branch information
renaudtertrais committed Nov 16, 2017
1 parent 1073760 commit cb3d4d6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React from 'react';
import PropTypes from 'prop-types';

import Indicator from './Indicator';
import provideTests from '../hoc/provideTests';
import provideJestResult from '../hoc/provideJestResult';
import colors from '../colors';

const TestsPanel = ({ tests }) => {
const Panel = ({ tests }) => {
const style = {
padding: '10px 20px',
flex: 1,
Expand Down Expand Up @@ -150,12 +150,12 @@ const TestsPanel = ({ tests }) => {
</div>
);
};
TestsPanel.propTypes = {
Panel.propTypes = {
tests: PropTypes.arrayOf(
PropTypes.shape({
result: PropTypes.object,
})
).isRequired,
};

export default provideTests(TestsPanel);
export default provideJestResult(Panel);
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import PropTypes from 'prop-types';

import provideTests from '../hoc/provideTests';
import provideJestResult from '../hoc/provideJestResult';
import Indicator from './Indicator';
import colors from '../colors';

const TestPanelTitle = ({ tests }) => {
const PanelTitle = ({ tests }) => {
if (!tests) {
return (
<div style={{ display: 'flex', alignItems: 'center' }}>
Expand All @@ -26,12 +26,12 @@ const TestPanelTitle = ({ tests }) => {
</div>
);
};
TestPanelTitle.propTypes = {
PanelTitle.propTypes = {
tests: PropTypes.arrayOf(
PropTypes.shape({
result: PropTypes.object,
})
).isRequired,
};

export default provideTests(TestPanelTitle);
export default provideJestResult(PanelTitle);
File renamed without changes.
8 changes: 4 additions & 4 deletions addons/jest/src/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import React from 'react';
import addons from '@storybook/addons';

import TestPanelTitle from './components/TestsPanelTitle';
import TestsPanel from './components/TestsPanel';
import PanelTitle from './components/PanelTitle';
import Panel from './components/Panel';

// Register the addon with a unique name.
addons.register('storybook/tests', api => {
// Also need to set a unique name to the panel.
addons.addPanel('storybook/tests/panel', {
title: <TestPanelTitle channel={addons.getChannel()} api={api} />,
render: () => <TestsPanel channel={addons.getChannel()} api={api} />,
title: <PanelTitle channel={addons.getChannel()} api={api} />,
render: () => <Panel channel={addons.getChannel()} api={api} />,
});
});
2 changes: 2 additions & 0 deletions examples/cra-kitchen-sink/.storybook/addons.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ import '@storybook/addon-options/register';
import '@storybook/addon-knobs/register';
import '@storybook/addon-backgrounds/register';
import '@storybook/addon-a11y/register';
import '@storybook/addon-jest/register';
import '@storybook/addon-jest/styles';
1 change: 1 addition & 0 deletions examples/cra-kitchen-sink/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@storybook/addon-centered": "^3.2.10",
"@storybook/addon-events": "^3.2.10",
"@storybook/addon-info": "^3.2.11",
"@storybook/addon-jest": "^3.2.11",
"@storybook/addon-knobs": "^3.2.10",
"@storybook/addon-links": "^3.2.10",
"@storybook/addon-notes": "^3.2.10",
Expand Down

0 comments on commit cb3d4d6

Please sign in to comment.