Skip to content

Commit

Permalink
Bubble up fixture updates from Loader #412
Browse files Browse the repository at this point in the history
  • Loading branch information
ovidiuch committed Aug 24, 2017
1 parent 6f15803 commit 486b63b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Expand Up @@ -22,15 +22,19 @@ const onComponentRef = () => {};
let wrapper;
let firstProxyWrapper;
let firstProxyProps;
let onFixtureUpdate;

describe('Fixture is selected via props', () => {
beforeEach(() => {
onFixtureUpdate = jest.fn();

wrapper = mount(
<Loader
proxies={[createProxyFoo]}
component={ComponentFooModule}
fixture={fixtureFooModule}
onComponentRef={onComponentRef}
onFixtureUpdate={onFixtureUpdate}
/>
);

Expand All @@ -57,4 +61,9 @@ describe('Fixture is selected via props', () => {
test('sends onComponentRef to first proxy', () => {
expect(firstProxyProps.onComponentRef).toEqual(onComponentRef);
});

test('bubbles up fixture updates', () => {
firstProxyProps.onFixtureUpdate({});
expect(onFixtureUpdate.mock.calls).toHaveLength(1);
});
});
4 changes: 2 additions & 2 deletions packages/react-cosmos-loader/src/components/Loader/index.js
Expand Up @@ -34,15 +34,15 @@ class Loader extends Component {

render() {
const { firstProxy } = this;
const { component, fixture, onComponentRef } = this.props;
const { component, fixture, onComponentRef, onFixtureUpdate } = this.props;

return (
<firstProxy.value
nextProxy={firstProxy.next()}
component={importComponent(component)}
fixture={importModule(fixture)}
onComponentRef={onComponentRef || noope}
onFixtureUpdate={noope}
onFixtureUpdate={onFixtureUpdate}
/>
);
}
Expand Down

0 comments on commit 486b63b

Please sign in to comment.