Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 8 additions & 6 deletions src/components/component-playground.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ module.exports = React.createClass({
<div className="header">
{this._renderButtons()}
<h1>
<a href={stringifyParams(homeUrlProps)}
<a ref="homeLink"
href={stringifyParams(homeUrlProps)}
className="home-link"
onClick={this.routeLink}>
onClick={this.props.router.routeLink}>
<span className="react">React</span> Component Playground
</a>
{_.isEmpty(this.state.fixtureContents) ? this._renderCosmosPlug()
Expand Down Expand Up @@ -170,9 +171,10 @@ module.exports = React.createClass({
return <li className={this._getFixtureClasses(componentName,
fixtureName)}
key={fixtureName}>
<a href={stringifyParams(fixtureProps)}
<a ref={componentName + fixtureName + 'Button'}
href={stringifyParams(fixtureProps)}
title={fixtureName}
onClick={this.routeLink}>
onClick={this.props.router.routeLink}>
{fixtureName}
</a>
</li>;
Expand Down Expand Up @@ -235,7 +237,7 @@ module.exports = React.createClass({
return <li className={classes}>
<a href={stringifyParams(fixtureEditorUrlProps)}
ref="fixtureEditorButton"
onClick={this.routeLink}>Editor</a>
onClick={this.props.router.routeLink}>Editor</a>
</li>;
},

Expand All @@ -249,7 +251,7 @@ module.exports = React.createClass({
return <li className="full-screen-button">
<a href={fullScreenUrl}
ref="fullScreenButton"
onClick={this.routeLink}>Fullscreen</a>
onClick={this.props.router.routeLink}>Fullscreen</a>
</li>;
},

Expand Down
5 changes: 4 additions & 1 deletion tests/components/component-playground/children.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ describe('ComponentPlayground component', function() {
sinon.stub(ComponentTree.loadChild, 'loadChild');

props = {
fixtures: {}
fixtures: {},
router: {
routeLink: sinon.spy()
}
};
});

Expand Down
35 changes: 34 additions & 1 deletion tests/components/component-playground/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ describe('ComponentPlayground component', function() {
sinon.stub(ComponentTree.loadChild, 'loadChild');

props = {
fixtures: {}
fixtures: {},
router: {
routeLink: sinon.spy()
}
};
});

Expand Down Expand Up @@ -90,6 +93,36 @@ describe('ComponentPlayground component', function() {
expect(expandedComponents.length).to.equal(1);
expect(expandedComponents[0]).to.equal('FirstComponent');
});

describe('router links', function() {
beforeEach(function() {
render({
selectedComponent: 'SecondComponent',
selectedFixture: 'simple state'
});
});

afterEach(function() {
expect(props.router.routeLink).to.have.been.called;
});

it('should route link on home button', function() {
utils.Simulate.click(component.refs.homeLink.getDOMNode());
});

it('should route link on component fixture button', function() {
utils.Simulate.click(
component.refs['SecondComponentsimple stateButton'].getDOMNode());
});

it('should route link on fixture editor button', function() {
utils.Simulate.click(component.refs.fixtureEditorButton.getDOMNode());
});

it('should route link on full screen button', function() {
utils.Simulate.click(component.refs.fullScreenButton.getDOMNode());
});
});
});

describe('editing fixture', function() {
Expand Down
3 changes: 3 additions & 0 deletions tests/components/component-playground/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ describe('ComponentPlayground component', function() {
SecondComponent: {
'simple state': {}
}
},
router: {
routeLink: sinon.spy()
}
};
});
Expand Down
3 changes: 3 additions & 0 deletions tests/components/component-playground/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ describe('ComponentPlayground component', function() {
myProp: true
}
}
},
router: {
routeLink: sinon.spy()
}
};
});
Expand Down