Skip to content

Commit

Permalink
Merge pull request #1744 from dangreenisrael/fixing-warnings
Browse files Browse the repository at this point in the history
Fixed Jest warnings
  • Loading branch information
ndelangen authored Aug 26, 2017
2 parents 381d4e8 + 9707280 commit e877afc
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 31 deletions.
24 changes: 12 additions & 12 deletions app/react/src/client/preview/client_api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('preview.client_api', () => {
},
});

api.storiesOf('none').aa();
api.storiesOf('none', module).aa();
expect(data).toBe('foo');
});

Expand All @@ -75,7 +75,7 @@ describe('preview.client_api', () => {
},
});

api.storiesOf('none').aa().bb();
api.storiesOf('none', module).aa().bb();
expect(data).toEqual(['foo', 'bar']);
});

Expand All @@ -89,7 +89,7 @@ describe('preview.client_api', () => {
},
});

api.storiesOf('none').aa();
api.storiesOf('none', module).aa();
expect(data).toBe('function');
});

Expand All @@ -109,7 +109,7 @@ describe('preview.client_api', () => {
},
});

api.storiesOf('none').bb();
api.storiesOf('none', module).bb();
expect(data).toBe('foo');
});

Expand All @@ -124,7 +124,7 @@ describe('preview.client_api', () => {
},
});

api.storiesOf(kind).aa();
api.storiesOf(kind, module).aa();
expect(data).toBe(kind);
});
});
Expand All @@ -133,7 +133,7 @@ describe('preview.client_api', () => {
it('should add local decorators', () => {
const storyStore = new StoryStore();
const api = new ClientAPI({ storyStore });
const localApi = api.storiesOf('none');
const localApi = api.storiesOf('none', module);
localApi.addDecorator(fn => `aa-${fn()}`);

localApi.add('storyName', () => 'Hello');
Expand All @@ -144,7 +144,7 @@ describe('preview.client_api', () => {
const storyStore = new StoryStore();
const api = new ClientAPI({ storyStore });
api.addDecorator(fn => `bb-${fn()}`);
const localApi = api.storiesOf('none');
const localApi = api.storiesOf('none', module);

localApi.add('storyName', () => 'Hello');
expect(storyStore.stories[0].fn()).toBe('bb-Hello');
Expand All @@ -153,7 +153,7 @@ describe('preview.client_api', () => {
it('should utilize both decorators at once', () => {
const storyStore = new StoryStore();
const api = new ClientAPI({ storyStore });
const localApi = api.storiesOf('none');
const localApi = api.storiesOf('none', module);

api.addDecorator(fn => `aa-${fn()}`);
localApi.addDecorator(fn => `bb-${fn()}`);
Expand All @@ -165,7 +165,7 @@ describe('preview.client_api', () => {
it('should pass the context', () => {
const storyStore = new StoryStore();
const api = new ClientAPI({ storyStore });
const localApi = api.storiesOf('none');
const localApi = api.storiesOf('none', module);
localApi.addDecorator(fn => `aa-${fn()}`);

localApi.add('storyName', ({ kind, story }) => `${kind}-${story}`);
Expand All @@ -180,7 +180,7 @@ describe('preview.client_api', () => {
it('should have access to the context', () => {
const storyStore = new StoryStore();
const api = new ClientAPI({ storyStore });
const localApi = api.storiesOf('none');
const localApi = api.storiesOf('none', module);
localApi.addDecorator((fn, { kind, story }) => `${kind}-${story}-${fn()}`);

localApi.add('storyName', () => 'Hello');
Expand Down Expand Up @@ -219,10 +219,10 @@ describe('preview.client_api', () => {
'story-2.1': () => 'story-2.1',
'story-2.2': () => 'story-2.2',
};
const kind1 = api.storiesOf('kind-1');
const kind1 = api.storiesOf('kind-1', module);
kind1.add('story-1.1', functions['story-1.1']);
kind1.add('story-1.2', functions['story-1.2']);
const kind2 = api.storiesOf('kind-2');
const kind2 = api.storiesOf('kind-2', module);
kind2.add('story-2.1', functions['story-2.1']);
kind2.add('story-2.2', functions['story-2.2']);
const book = api.getStorybook();
Expand Down
24 changes: 12 additions & 12 deletions app/vue/src/client/preview/client_api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('preview.client_api', () => {
},
});

api.storiesOf('none').aa();
api.storiesOf('none', module).aa();
expect(data).toBe('foo');
});

Expand All @@ -75,7 +75,7 @@ describe('preview.client_api', () => {
},
});

api.storiesOf('none').aa().bb();
api.storiesOf('none', module).aa().bb();
expect(data).toEqual(['foo', 'bar']);
});

Expand All @@ -89,7 +89,7 @@ describe('preview.client_api', () => {
},
});

api.storiesOf('none').aa();
api.storiesOf('none', module).aa();
expect(data).toBe('function');
});

Expand All @@ -109,7 +109,7 @@ describe('preview.client_api', () => {
},
});

api.storiesOf('none').bb();
api.storiesOf('none', module).bb();
expect(data).toBe('foo');
});

Expand All @@ -124,7 +124,7 @@ describe('preview.client_api', () => {
},
});

api.storiesOf(kind).aa();
api.storiesOf(kind, module).aa();
expect(data).toBe(kind);
});
});
Expand All @@ -133,7 +133,7 @@ describe('preview.client_api', () => {
it('should add local decorators', () => {
const storyStore = new StoryStore();
const api = new ClientAPI({ storyStore });
const localApi = api.storiesOf('none');
const localApi = api.storiesOf('none', module);
localApi.addDecorator(fn => ({ template: `<div>aa${fn().template}</div>` }));

localApi.add('storyName', () => ({ template: '<p>hello</p>' }));
Expand All @@ -144,7 +144,7 @@ describe('preview.client_api', () => {
const storyStore = new StoryStore();
const api = new ClientAPI({ storyStore });
api.addDecorator(fn => ({ template: `<div>bb${fn().template}</div>` }));
const localApi = api.storiesOf('none');
const localApi = api.storiesOf('none', module);

localApi.add('storyName', () => ({ template: '<p>hello</p>' }));
expect(storyStore.stories[0].fn().template).toBe('<div>bb<p>hello</p></div>');
Expand All @@ -153,7 +153,7 @@ describe('preview.client_api', () => {
it('should utilize both decorators at once', () => {
const storyStore = new StoryStore();
const api = new ClientAPI({ storyStore });
const localApi = api.storiesOf('none');
const localApi = api.storiesOf('none', module);

api.addDecorator(fn => ({ template: `<div>aa${fn().template}</div>` }));
localApi.addDecorator(fn => ({ template: `<div>bb${fn().template}</div>` }));
Expand All @@ -165,7 +165,7 @@ describe('preview.client_api', () => {
it('should pass the context', () => {
const storyStore = new StoryStore();
const api = new ClientAPI({ storyStore });
const localApi = api.storiesOf('none');
const localApi = api.storiesOf('none', module);
localApi.addDecorator(fn => ({ template: `<div>aa${fn().template}</div>` }));

localApi.add('storyName', ({ kind, story }) => ({ template: `<p>${kind}-${story}</p>` }));
Expand All @@ -180,7 +180,7 @@ describe('preview.client_api', () => {
it('should have access to the context', () => {
const storyStore = new StoryStore();
const api = new ClientAPI({ storyStore });
const localApi = api.storiesOf('none');
const localApi = api.storiesOf('none', module);
localApi.addDecorator((fn, { kind, story }) => ({
template: `<div>${kind}-${story}-${fn().template}</div>`,
}));
Expand Down Expand Up @@ -221,10 +221,10 @@ describe('preview.client_api', () => {
'story-2.1': () => 'story-2.1',
'story-2.2': () => 'story-2.2',
};
const kind1 = api.storiesOf('kind-1');
const kind1 = api.storiesOf('kind-1', module);
kind1.add('story-1.1', functions['story-1.1']);
kind1.add('story-1.2', functions['story-1.2']);
const kind2 = api.storiesOf('kind-2');
const kind2 = api.storiesOf('kind-2', module);
kind2.add('story-2.1', functions['story-2.1']);
kind2.add('story-2.2', functions['story-2.2']);
const book = api.getStorybook();
Expand Down
6 changes: 6 additions & 0 deletions lib/ui/src/modules/ui/components/layout/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describe('manager.ui.components.layout.index', () => {
showLeftPanel
showDownPanel
goFullScreen={false}
downPanelInRight={false}
leftPanel={() => 'LeftPanel'}
downPanel={() => 'DownPanel'}
preview={() => 'Preview'}
Expand All @@ -28,6 +29,9 @@ describe('manager.ui.components.layout.index', () => {
const wrap = shallow(
<Layout
goFullScreen
showDownPanel={false}
showLeftPanel={false}
downPanelInRight={false}
leftPanel={() => 'LeftPanel'}
downPanel={() => 'DownPanel'}
preview={() => 'Preview'}
Expand All @@ -47,6 +51,7 @@ describe('manager.ui.components.layout.index', () => {
<Layout
showLeftPanel={false}
showDownPanel
downPanelInRight={false}
goFullScreen={false}
leftPanel={() => 'LeftPanel'}
downPanel={() => 'DownPanel'}
Expand All @@ -68,6 +73,7 @@ describe('manager.ui.components.layout.index', () => {
showLeftPanel
showDownPanel={false}
goFullScreen={false}
downPanelInRight={false}
leftPanel={() => 'LeftPanel'}
downPanel={() => 'DownPanel'}
preview={() => 'Preview'}
Expand Down
8 changes: 6 additions & 2 deletions lib/ui/src/modules/ui/components/menu_item.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ const keyCodeEnter = 13;
describe('manager.ui.components.menu_item', () => {
describe('render', () => {
test('should use "a" tag', () => {
const wrap = shallow(<MenuItem title="title">Content</MenuItem>);
const wrap = shallow(
<MenuItem title="title" onClick={() => undefined}>
Content
</MenuItem>
);

expect(
wrap.matchesElement(
Expand All @@ -25,7 +29,7 @@ describe('manager.ui.components.menu_item', () => {

beforeEach(() => {
onClick = jest.fn();
wrap = shallow(<MenuItem onClick={onClick} />);
wrap = shallow(<MenuItem onClick={onClick}>Content</MenuItem>);
});

test('should call onClick on a click', () => {
Expand Down
19 changes: 14 additions & 5 deletions lib/ui/src/modules/ui/components/search_box.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ import FuzzySearch from '@storybook/react-fuzzy';
import SearchBox from './search_box';

describe('manager.ui.components.search_box', () => {
const defaultProps = {
showSearchBox: false,
onSelectStory: () => undefined,
onClose: () => undefined,
};
describe('render', () => {
test('should render FuzzySearch inside ReactModal', () => {
const wrap = shallow(<SearchBox showSearchBox />);
const wrap = shallow(<SearchBox {...defaultProps} showSearchBox />);

const modal = wrap.find(ReactModal);
expect(modal).toBePresent();
Expand All @@ -28,7 +33,7 @@ describe('manager.ui.components.search_box', () => {
stories: ['b', 'c'],
},
];
const wrap = shallow(<SearchBox stories={stories} />);
const wrap = shallow(<SearchBox {...defaultProps} stories={stories} />);
const search = wrap.find(FuzzySearch);

const expectedList = [
Expand Down Expand Up @@ -57,7 +62,7 @@ describe('manager.ui.components.search_box', () => {
describe('events', () => {
test('should call the onClose prop when modal requests it', () => {
const onClose = jest.fn();
const wrap = shallow(<SearchBox onClose={onClose} />);
const wrap = shallow(<SearchBox {...defaultProps} onClose={onClose} />);

const modal = wrap.find(ReactModal);
modal.simulate('requestClose');
Expand All @@ -68,7 +73,9 @@ describe('manager.ui.components.search_box', () => {
test('should handle selecting a kind', () => {
const onSelectStory = jest.fn();
const onClose = jest.fn();
const wrap = shallow(<SearchBox onSelectStory={onSelectStory} onClose={onClose} />);
const wrap = shallow(
<SearchBox {...defaultProps} onSelectStory={onSelectStory} onClose={onClose} />
);

const modal = wrap.find(FuzzySearch);
modal.simulate('select', {
Expand All @@ -83,7 +90,9 @@ describe('manager.ui.components.search_box', () => {
test('should handle selecting a story', () => {
const onSelectStory = jest.fn();
const onClose = jest.fn();
const wrap = shallow(<SearchBox onSelectStory={onSelectStory} onClose={onClose} />);
const wrap = shallow(
<SearchBox {...defaultProps} onSelectStory={onSelectStory} onClose={onClose} />
);

const modal = wrap.find(FuzzySearch);
modal.simulate('select', {
Expand Down

0 comments on commit e877afc

Please sign in to comment.