Skip to content

Commit

Permalink
use composeAllWithStub defined in PR storybookjs/storybook#85 instead…
Browse files Browse the repository at this point in the history
… of disable(). This enables proper rendering of the nested container components. Specifically:

- story comments.CommentList now shows the CreateComment properly
- story core.Post now shows the CommentList properly
  • Loading branch information
ihealthdavid committed Jun 16, 2016
1 parent 1334910 commit cabd511
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .storybook/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { configure } from '@kadira/storybook';
import { disable } from 'react-komposer';
import { setTestMode } from 'react-komposer';

disable();
setTestMode();

function loadStories() {
require('../client/modules/core/components/.stories');
Expand Down
17 changes: 14 additions & 3 deletions client/modules/comments/containers/comment_list.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {
useDeps, composeWithTracker, composeAll
useDeps, composeWithTracker, compose, composeAll
} from 'mantra-core';
import Component from '../components/comment_list';
import { composeAllWithStub } from 'react-komposer';

export const composer = ({context, clearErrors, postId}, onData) => {
const {Meteor, Collections} = context();
Expand All @@ -16,7 +17,17 @@ export const composer = ({context, clearErrors, postId}, onData) => {
}
};

export default composeAll(
export const composerStub = ({context, clearErrors}, onData) => {
const comments = [
{_id: 'one', text: 'This is cool.', author: 'arunoda'},
{_id: 'two', text: 'Yeah! I agree.', author: 'sacha'},
];

onData(null, {comments});
};
export default composeAllWithStub([
composeWithTracker(composer),
useDeps()
)(Component);
],[
compose(composerStub),
])(Component);
21 changes: 18 additions & 3 deletions client/modules/comments/containers/create_comment.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {
useDeps, composeWithTracker, composeAll
useDeps, composeWithTracker, compose, composeAll
} from 'mantra-core';
import Component from '../components/create_comment';
import { composeAllWithStub } from 'react-komposer';

export const composer = ({context, clearErrors}, onData) => {
const {LocalState} = context();
Expand All @@ -17,7 +18,21 @@ export const depsMapper = (context, actions) => ({
context: () => context
});

export default composeAll(
export const composerStub = ({context, clearErrors}, onData) => {
onData(null, 'data`');
return clearErrors;
};

export const depsMapperStub = (context, actions) => ({
create: (x)=>console.log('create',x),
clearErrors: (x)=>console.log('clearErrors',x),
context: () => context
});

export default composeAllWithStub([
composeWithTracker(composer),
useDeps(depsMapper)
)(Component);
],[
compose(composerStub),
useDeps(depsMapperStub)
])(Component);

0 comments on commit cabd511

Please sign in to comment.