Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storybook UI theming #3628

Merged
merged 118 commits into from
Jul 1, 2018
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
898c1f4
WIP
ndelangen May 19, 2018
bae0a2a
Merge branch 'feature/more-components' into feature/theming
ndelangen May 19, 2018
f546481
FIX drag blocker
ndelangen May 20, 2018
ee4a416
REFACTOR consolidate Tabs component && CHANGE registerAddon api to in…
ndelangen May 22, 2018
c6e704c
DOCUMENT new api for registering addon panels
ndelangen May 22, 2018
4c39c8b
CHANGE location and styling of Dimensions component
ndelangen May 22, 2018
313486f
FIX tests
ndelangen May 22, 2018
b45b078
Merge branch 'master' into feature/theming
ndelangen May 22, 2018
4ea75bb
REMOVE mobile header
ndelangen May 23, 2018
b668f5a
ADD theme variables for Tabs
ndelangen May 23, 2018
af097bc
FIX snapshots
ndelangen May 24, 2018
af506f2
Merge branch 'master' into feature/theming
ndelangen May 24, 2018
e6096cc
CHANGE to use custom version of react-treebeard with emotion for styling
ndelangen May 24, 2018
e9ce090
REMOVE basefonts from jest-addon Panel
ndelangen May 24, 2018
eddf2b7
REMOVE basefonts from viewport stories
ndelangen May 24, 2018
74de615
REMOVE basefonts from button
ndelangen May 24, 2018
79fc816
REMOVE basefonts from dimensions
ndelangen May 24, 2018
f72ce62
REMOVE basefonts from placeholder
ndelangen May 24, 2018
63613ec
FIX typo in Tabs stories
ndelangen May 24, 2018
92850ed
REMOVE basefonts from searchbox
ndelangen May 24, 2018
011142c
REMOVE basefonts from shortcuthelp
ndelangen May 24, 2018
98dc2fa
IMRPOVE theming for stories panel
ndelangen May 24, 2018
a2af2be
IMPROVE background theming
ndelangen May 24, 2018
f00243a
FIX & REFACTOR search box
ndelangen May 24, 2018
78c9a3e
FIX snapshots
ndelangen May 25, 2018
57c50f4
IMPROVE theme
ndelangen May 25, 2018
35c8838
WIP
ndelangen May 26, 2018
c801905
WIP
ndelangen May 27, 2018
2f5cf2f
ADD PanelActionBar component
ndelangen May 27, 2018
4230448
IMPROVE styling ActionBar
ndelangen May 27, 2018
ac9278f
FIX performance addon-knobs && REMOVE knobs in URLquery && ADD copy k…
ndelangen May 27, 2018
2a49259
Merge branch 'master' into feature/theming
ndelangen May 27, 2018
bab52c7
WIP
ndelangen May 28, 2018
b8f8d95
FIX knobs speed && REMOVE throttle
ndelangen May 28, 2018
8714ed7
ADD bordered mode for Tabs
ndelangen May 28, 2018
87be909
CLEANUP
ndelangen May 28, 2018
b6549d6
FIX speed knobs object type
ndelangen May 28, 2018
9187462
FIX linting
ndelangen May 28, 2018
d0b507e
FIX tests
ndelangen May 28, 2018
dd6037f
Merge branch 'master' into feature/theming
ndelangen May 30, 2018
26fe6f5
FIX knobs Array
ndelangen May 30, 2018
e76e9c7
Only run a11y analysis on demand
manuel-magnetix May 30, 2018
46cdbac
Use named export for event name
manuel-magnetix May 30, 2018
5c32f8e
ADD theming support for addon-action
ndelangen May 30, 2018
8701b83
ADD dark theme && ADD theme for action react-inspector
ndelangen May 30, 2018
b542d4c
FIX colour text in button of ActionBar
ndelangen May 30, 2018
5fc9c08
Merge pull request #3690 from DerJacques/feature/only-run-a11y-on-demand
ndelangen May 30, 2018
8366b67
ADD success & fail colours to theme
ndelangen May 30, 2018
978e7e5
CONSOLIDATE a11y ActionBar && theme a11y addon
ndelangen May 30, 2018
5ac92f3
IMPROVE styling of a11y header
ndelangen May 30, 2018
26b2bc5
ADD theming for addon-background
ndelangen May 30, 2018
407369b
FIX addon-notes so stateful containers always renders
ndelangen May 30, 2018
3ce57aa
FIX snapshots
ndelangen May 31, 2018
fb372a0
FIX theming of a11y
ndelangen May 31, 2018
c3f43d9
FIX lint issues
ndelangen May 31, 2018
12237db
FIX snapshot
ndelangen May 31, 2018
6d3c806
IMPROVE tabs
ndelangen May 31, 2018
996d276
theme knobs array
ndelangen Jun 1, 2018
9d503c2
REFACTOR form components
ndelangen Jun 1, 2018
7395379
ADD react-textarea-autosize to components
ndelangen Jun 1, 2018
4389c20
FIX tabs overflow
ndelangen Jun 1, 2018
cc68e66
theme viewport
ndelangen Jun 1, 2018
d2faeb7
REFACTOR knobs field to use field component
ndelangen Jun 1, 2018
1a5e90d
ADD todo statement to add theming for storysource addon
ndelangen Jun 1, 2018
41badab
theme knobs button
ndelangen Jun 1, 2018
1b5daf3
theme knobs color
ndelangen Jun 1, 2018
19bf77c
theme knobs files
ndelangen Jun 1, 2018
b642121
theme knobs number
ndelangen Jun 1, 2018
e66d323
theme knobs object
ndelangen Jun 1, 2018
29ac4c8
theme knobs select
ndelangen Jun 1, 2018
18ef6de
theme knobs text
ndelangen Jun 1, 2018
f877ac9
theme knobs date
ndelangen Jun 1, 2018
bd595a4
FIX knob object
ndelangen Jun 1, 2018
398bcf9
IMPROVE themes
ndelangen Jun 1, 2018
44a8c36
ADD displayNames to styled components to improve debugging & snapshots
ndelangen Jun 1, 2018
370b56f
REMOVE unneeded components
ndelangen Jun 1, 2018
1ded5f9
FIX unittest && FIX snapshots
ndelangen Jun 2, 2018
c49dff9
CLEANUP remove redundant dependencies
ndelangen Jun 2, 2018
9ea4117
REMOVE commented code
ndelangen Jun 2, 2018
44fb086
CLEANUP knobs panel
ndelangen Jun 2, 2018
a1bdf16
REFACTOR knobs PropField &7 REMOVE redundant component && ADD theme v…
ndelangen Jun 2, 2018
6d198dd
ADD validation styles to form input && ADD stories
ndelangen Jun 2, 2018
9c3788c
ADD theming to header
ndelangen Jun 2, 2018
0289456
ADD stories for bordered tabs
ndelangen Jun 2, 2018
53ba1cf
REFACTOR move ThemeProvider to ui root && ADD theming for modal
ndelangen Jun 2, 2018
f735795
FIX shortcurts help story
ndelangen Jun 2, 2018
28eb275
FIX correct prop to have defaultValue for Textarea story
ndelangen Jun 2, 2018
313c8f3
FIX storyshots & snapshots
ndelangen Jun 2, 2018
6ec6328
Merge branch 'master' into feature/theming
ndelangen Jun 2, 2018
128066d
theme searchbox && FIX unittest
ndelangen Jun 2, 2018
b022803
FIX linting
ndelangen Jun 2, 2018
d90aa8d
FIX linting
ndelangen Jun 2, 2018
1dba82b
ADD ability to set theme using setOptions
ndelangen Jun 3, 2018
677558c
Compose containers with withRef = false to fix react warnings
shilman Jun 3, 2018
a5d5567
Layout theme can be null so it shouldn't be a required prop
shilman Jun 3, 2018
c4cee7a
Render addon panels inside a fragment with key to remove warnings
shilman Jun 3, 2018
b2c3d90
Merge branch 'master' into feature/theming
ndelangen Jun 3, 2018
fe0311f
Fix broken snapshot tests for layout with required parameters
shilman Jun 3, 2018
9344955
Merge branch 'feature/theming' of github.com:storybooks/storybook int…
ndelangen Jun 4, 2018
959880e
CHANGE layoutMargin
ndelangen Jun 4, 2018
9d2a015
RENAME 'React Storybook' to 'Storybook'
ndelangen Jun 4, 2018
7d14ef9
ADD docs for theming
ndelangen Jun 4, 2018
97b8165
FIX alignment bug && FIX snapshot
ndelangen Jun 5, 2018
b3ca126
ADD explanation for knobstore's complex code && RENAME equal to deepE…
ndelangen Jun 6, 2018
691aece
FIX jest addon panel not rendering when switching panels
ndelangen Jun 6, 2018
2995b30
Improve writing-addons doc to mention theming & re-using components
ndelangen Jun 6, 2018
2991bc3
FIX minor typo
ndelangen Jun 6, 2018
a9cdac8
FIX barBorder in dark theme being barely visible
ndelangen Jun 6, 2018
18b5a43
Merge branch 'master' into feature/theming
ndelangen Jun 6, 2018
0e84684
FIX theme of shortcutModal & searchboxModal
ndelangen Jun 13, 2018
ed96067
Merge branch 'master' into feature/theming
ndelangen Jun 13, 2018
0a2a99c
CLEANUP
ndelangen Jun 13, 2018
62d1236
FIX snapshots
ndelangen Jun 13, 2018
61e0b4a
Merge branch 'master' into feature/theming
ndelangen Jun 21, 2018
c626f54
Merge branch 'master' into feature/theming
ndelangen Jun 21, 2018
79a5e34
REFACTOR Tabs to use children for data
ndelangen Jun 21, 2018
6db311d
FIX snapshots and Tabs implementation
ndelangen Jun 25, 2018
0dce8f9
Merge branch 'master' into feature/theming
Hypnosphi Jun 28, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 20 additions & 16 deletions addons/a11y/src/components/Panel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import addons from '@storybook/addons';
import PropTypes from 'prop-types';

import styled from 'react-emotion';

Expand All @@ -17,36 +17,40 @@ const Violations = styled('span')({
});

class Panel extends Component {
constructor(props, ...args) {
super(props, ...args);
this.state = {
passes: [],
violations: [],
};
this.channel = addons.getChannel();
static propTypes = {
active: PropTypes.bool.isRequired,
channel: PropTypes.shape({
on: PropTypes.func,
emit: PropTypes.func,
removeListener: PropTypes.func,
}).isRequired,
};

this.onUpdate = this.onUpdate.bind(this);
}
state = {
passes: [],
violations: [],
};

componentDidMount() {
this.channel.on(CHECK_EVENT_ID, this.onUpdate);
this.props.channel.on(CHECK_EVENT_ID, this.onUpdate);
}

componentWillUnmount() {
this.channel.removeListener(CHECK_EVENT_ID, this.onUpdate);
this.props.channel.removeListener(CHECK_EVENT_ID, this.onUpdate);
}

onUpdate({ passes, violations }) {
onUpdate = ({ passes, violations }) => {
this.setState({
passes,
violations,
});
}
};

render() {
const { passes, violations } = this.state;
const { active } = this.props;

return (
return active ? (
<Tabs
tabs={[
{
Expand All @@ -59,7 +63,7 @@ class Panel extends Component {
},
]}
/>
);
) : null;
}
}

Expand Down
1 change: 1 addition & 0 deletions addons/a11y/src/components/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import styled from 'react-emotion';
const Container = styled('div')({
width: '100%',
position: 'relative',
minHeight: '100%',
});

const List = styled('div')({
Expand Down
8 changes: 4 additions & 4 deletions addons/a11y/src/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import Panel from './components/Panel';
import { ADDON_ID, PANEL_ID } from './shared';

function init() {
addons.register(ADDON_ID, () => {
addons.register(ADDON_ID, api => {
const channel = addons.getChannel();
addons.addPanel(PANEL_ID, {
title: 'Accessibility',
render() {
return <Panel />;
},
// eslint-disable-next-line react/prop-types
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally not a huge fan of these. Is there a reason?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm passing down a function, not a component..

Or is the comment regarding the switched based on active?

render: ({ active }) => <Panel channel={channel} api={api} active={active} />,
});
});
}
Expand Down
1 change: 1 addition & 0 deletions addons/actions/src/components/ActionLogger/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ export const Wrapper = styled('div')({
flex: 1,
display: 'flex',
position: 'relative',
minHeight: '100%',
});
18 changes: 11 additions & 7 deletions addons/actions/src/containers/ActionLogger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,25 @@ export default class ActionLogger extends React.Component {
}

render() {
const { active } = this.props;
const props = {
actions: this.state.actions,
onClear: () => this.clearActions(),
};
return <ActionLoggerComponent {...props} />;
return active ? <ActionLoggerComponent {...props} /> : null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personal preference, add a conditional to return null instead of using a ternary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would your solution look like?

An if statement above?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah :)

if (!active) {
  return null;
}

return <ActionLoggerComponent {...props} />;

I do this because I can change the two conditions easier if needed and it makes it more readable imho.

}
}

ActionLogger.propTypes = {
// eslint-disable-next-line react/forbid-prop-types
channel: PropTypes.object,
active: PropTypes.bool.isRequired,
channel: PropTypes.shape({
emit: PropTypes.func,
on: PropTypes.func,
removeListener: PropTypes.func,
}).isRequired,
api: PropTypes.shape({
onStory: PropTypes.func.isRequired,
onStory: PropTypes.func,
getQueryParam: PropTypes.func,
setQueryParams: PropTypes.func,
}).isRequired,
};
ActionLogger.defaultProps = {
channel: {},
};
3 changes: 2 additions & 1 deletion addons/actions/src/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export function register() {
const channel = addons.getChannel();
addons.addPanel(PANEL_ID, {
title: 'Action Logger',
render: () => <ActionLogger channel={channel} api={api} />,
// eslint-disable-next-line react/prop-types
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

render: ({ active }) => <ActionLogger channel={channel} api={api} active={active} />,
});
});
}
6 changes: 5 additions & 1 deletion addons/backgrounds/src/BackgroundPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,11 @@ export default class BackgroundPanel extends Component {
}

render() {
const { active } = this.props;
const backgrounds = [...this.state.backgrounds];

if (!active) {
return null;
}
if (!backgrounds.length) return <Instructions />;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline between statements, and curly braces? Not sure what the rules here are.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If eslint passes then it's OK


const hasDefault = backgrounds.filter(x => x.default).length;
Expand All @@ -149,6 +152,7 @@ export default class BackgroundPanel extends Component {
}
}
BackgroundPanel.propTypes = {
active: PropTypes.bool.isRequired,
api: PropTypes.shape({
getQueryParam: PropTypes.func,
setQueryParams: PropTypes.func,
Expand Down
30 changes: 20 additions & 10 deletions addons/backgrounds/src/__tests__/BackgroundPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,50 +30,54 @@ jest.mock('global', () => ({

describe('Background Panel', () => {
it('should exist', () => {
const backgroundPanel = shallow(<BackgroundPanel channel={channel} api={mockedApi} />);
const backgroundPanel = shallow(<BackgroundPanel channel={channel} api={mockedApi} active />);

expect(backgroundPanel).toBeDefined();
});

it('should have a default background value of transparent', () => {
const backgroundPanel = shallow(<BackgroundPanel channel={channel} api={mockedApi} />);
const backgroundPanel = shallow(<BackgroundPanel channel={channel} api={mockedApi} active />);

expect(backgroundPanel.state().backgrounds).toHaveLength(0);
});

it('should show setup instructions if no colors provided', () => {
const backgroundPanel = shallow(<BackgroundPanel channel={channel} api={mockedApi} />);
const backgroundPanel = shallow(<BackgroundPanel channel={channel} api={mockedApi} active />);

expect(backgroundPanel.html().match(/Setup Instructions/gim).length).toBeGreaterThan(0);
});

it('should set the query string', () => {
const SpiedChannel = new EventEmitter();
mount(<BackgroundPanel channel={SpiedChannel} api={mockedApi} />);
mount(<BackgroundPanel channel={SpiedChannel} api={mockedApi} active />);
SpiedChannel.emit(Events.SET, backgrounds);

expect(mockedApi.getQueryParam).toBeCalledWith('background');
});

it('should not unset the query string', () => {
const SpiedChannel = new EventEmitter();
mount(<BackgroundPanel channel={SpiedChannel} api={mockedApi} />);
mount(<BackgroundPanel channel={SpiedChannel} api={mockedApi} active />);
SpiedChannel.emit(Events.UNSET, []);

expect(mockedApi.setQueryParams).not.toHaveBeenCalled();
});

it('should accept colors through channel and render the correct swatches with a default swatch', () => {
const SpiedChannel = new EventEmitter();
const backgroundPanel = mount(<BackgroundPanel channel={SpiedChannel} api={mockedApi} />);
const backgroundPanel = mount(
<BackgroundPanel channel={SpiedChannel} api={mockedApi} active />
);
SpiedChannel.emit(Events.SET, backgrounds);

expect(backgroundPanel.state('backgrounds')).toEqual(backgrounds);
});

it('should allow setting a default swatch', () => {
const SpiedChannel = new EventEmitter();
const backgroundPanel = mount(<BackgroundPanel channel={SpiedChannel} api={mockedApi} />);
const backgroundPanel = mount(
<BackgroundPanel channel={SpiedChannel} api={mockedApi} active />
);
const [head, ...tail] = backgrounds;
const localBgs = [{ ...head, default: true }, ...tail];
SpiedChannel.emit(Events.SET, localBgs);
Expand All @@ -88,7 +92,9 @@ describe('Background Panel', () => {

it('should allow the default swatch become the background color', () => {
const SpiedChannel = new EventEmitter();
const backgroundPanel = mount(<BackgroundPanel channel={SpiedChannel} api={mockedApi} />);
const backgroundPanel = mount(
<BackgroundPanel channel={SpiedChannel} api={mockedApi} active />
);
const [head, second, ...tail] = backgrounds;
const localBgs = [head, { ...second, default: true }, ...tail];
SpiedChannel.on('background', bg => {
Expand All @@ -106,7 +112,9 @@ describe('Background Panel', () => {

it('should unset all swatches on receiving the background-unset message', () => {
const SpiedChannel = new EventEmitter();
const backgroundPanel = mount(<BackgroundPanel channel={SpiedChannel} api={mockedApi} />);
const backgroundPanel = mount(
<BackgroundPanel channel={SpiedChannel} api={mockedApi} active />
);
SpiedChannel.emit(Events.SET, backgrounds);

expect(backgroundPanel.state('backgrounds')).toEqual(backgrounds);
Expand All @@ -118,7 +126,9 @@ describe('Background Panel', () => {

it('should set iframe background', () => {
const SpiedChannel = new EventEmitter();
const backgroundPanel = mount(<BackgroundPanel channel={SpiedChannel} api={mockedApi} />);
const backgroundPanel = mount(
<BackgroundPanel channel={SpiedChannel} api={mockedApi} active />
);
backgroundPanel.setState({ backgrounds }); // force re-render

backgroundPanel
Expand Down
3 changes: 2 additions & 1 deletion addons/backgrounds/src/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ addons.register(ADDON_ID, api => {
const channel = addons.getChannel();
addons.addPanel(PANEL_ID, {
title: 'Backgrounds',
render: () => <BackgroundPanel channel={channel} api={api} />,
// eslint-disable-next-line react/prop-types
render: ({ active }) => <BackgroundPanel channel={channel} api={api} active={active} />,
});
});
7 changes: 5 additions & 2 deletions addons/events/src/components/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ const Wrapper = styled('div')({
width: '100%',
boxSizing: 'border-box',
padding: '10px',
minHeight: '100%',
});

export default class Events extends Component {
static propTypes = {
active: PropTypes.bool.isRequired,
channel: PropTypes.shape({
on: PropTypes.func,
emit: PropTypes.func,
Expand Down Expand Up @@ -43,10 +45,11 @@ export default class Events extends Component {

render() {
const { events } = this.state;
return (
const { active } = this.props;
return active ? (
<Wrapper>
{events.map(event => <Event key={event.name} {...event} onEmit={this.onEmit} />)}
</Wrapper>
);
) : null;
}
}
4 changes: 3 additions & 1 deletion addons/events/src/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import { ADDON_ID, PANEL_ID } from './constants';

export function register() {
addons.register(ADDON_ID, () => {
const channel = addons.getChannel();
addons.addPanel(PANEL_ID, {
title: 'Events',
render: () => <Panel channel={addons.getChannel()} />,
// eslint-disable-next-line react/prop-types
render: ({ active }) => <Panel channel={channel} active={active} />,
});
});
}
6 changes: 3 additions & 3 deletions addons/jest/src/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import addons from '@storybook/addons';
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.
const channel = addons.getChannel();
addons.addPanel('storybook/tests/panel', {
title: <PanelTitle channel={addons.getChannel()} api={api} />,
render: () => <Panel channel={addons.getChannel()} api={api} />,
// eslint-disable-next-line react/prop-types
render: ({ active }) => (active ? <Panel channel={channel} api={api} /> : null),
});
});
8 changes: 7 additions & 1 deletion addons/knobs/src/components/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ export default class Panel extends React.Component {

render() {
const { knobs, groupId } = this.state;
const { active } = this.props;

if (!active) {
return null;
}

const groups = {};
const groupIds = [];
Expand Down Expand Up @@ -190,12 +195,13 @@ export default class Panel extends React.Component {
}

Panel.propTypes = {
active: PropTypes.bool.isRequired,
onReset: PropTypes.object, // eslint-disable-line
channel: PropTypes.shape({
emit: PropTypes.func,
on: PropTypes.func,
removeListener: PropTypes.func,
}).isRequired,
onReset: PropTypes.object, // eslint-disable-line
api: PropTypes.shape({
onStory: PropTypes.func,
getQueryParam: PropTypes.func,
Expand Down
10 changes: 5 additions & 5 deletions addons/knobs/src/components/__tests__/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ describe('Panel', () => {
it('should subscribe to setKnobs event of channel', () => {
const testChannel = { on: jest.fn() };
const testApi = { onStory: jest.fn() };
shallow(<Panel channel={testChannel} api={testApi} />);
shallow(<Panel channel={testChannel} api={testApi} active />);
expect(testChannel.on).toHaveBeenCalledWith('addon:knobs:setKnobs', jasmine.any(Function));
});

it('should subscribe to onStory event', () => {
const testChannel = { on: jest.fn() };
const testApi = { onStory: jest.fn() };
shallow(<Panel channel={testChannel} api={testApi} />);
shallow(<Panel channel={testChannel} api={testApi} active />);

expect(testApi.onStory).toHaveBeenCalled();
expect(testChannel.on).toHaveBeenCalledWith('addon:knobs:setKnobs', jasmine.any(Function));
Expand Down Expand Up @@ -41,7 +41,7 @@ describe('Panel', () => {
onStory: jest.fn(),
};

shallow(<Panel channel={testChannel} api={testApi} />);
shallow(<Panel channel={testChannel} api={testApi} active />);
const setKnobsHandler = handlers['addon:knobs:setKnobs'];

const knobs = {
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('Panel', () => {
onStory: jest.fn(),
};

const wrapper = shallow(<Panel channel={testChannel} api={testApi} />);
const wrapper = shallow(<Panel channel={testChannel} api={testApi} active />);
const setKnobsHandler = handlers['addon:knobs:setKnobs'];

const knobs = {
Expand Down Expand Up @@ -130,7 +130,7 @@ describe('Panel', () => {
onStory: jest.fn(),
};

const wrapper = shallow(<Panel channel={testChannel} api={testApi} />);
const wrapper = shallow(<Panel channel={testChannel} api={testApi} active />);

const testChangedKnob = {
name: 'foo',
Expand Down