mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-01 05:05:25 +08:00
Improve test coverage
This commit is contained in:
parent
868dcedd12
commit
1e2892f2f1
@ -2,22 +2,56 @@
|
||||
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import AddonInfo, { withInfo } from './';
|
||||
import AddonInfo, { withInfo, setDefaults, addInfo } from './';
|
||||
|
||||
/* eslint-disable */
|
||||
const TestComponent = ({ func, obj, array, number, string, bool, empty }) =>
|
||||
<div>
|
||||
<h1>{func}</h1>
|
||||
<h2>{obj.toString()}</h2>
|
||||
<h3>{array}</h3>
|
||||
<h4>{number}</h4>
|
||||
<h5>{string}</h5>
|
||||
<h6>{bool}</h6>
|
||||
<p>{empty}</p>
|
||||
<a href="#">test</a>
|
||||
<code>storiesOf</code>
|
||||
<ui>
|
||||
<li>1</li>
|
||||
<li>2</li>
|
||||
</ui>
|
||||
</div>;
|
||||
/* eslint-enable */
|
||||
|
||||
const testContext = { kind: 'addon_info', story: 'jest_test' };
|
||||
const testOptions = { propTables: false };
|
||||
|
||||
describe('addon Info', () => {
|
||||
const story = context =>
|
||||
<div>
|
||||
It's a {context.story} story
|
||||
It's a {context.story} story:
|
||||
<TestComponent
|
||||
func={x => x + 1}
|
||||
obj={{ a: 'a', b: 'b' }}
|
||||
array={[1, 2, 3]}
|
||||
number={7}
|
||||
string={'seven'}
|
||||
bool
|
||||
/>
|
||||
</div>;
|
||||
const api = {
|
||||
add: (name, fn) => fn({ kind: 'addon_info', story: 'jest_test' }),
|
||||
add: (name, fn) => fn(testContext),
|
||||
};
|
||||
it('should render <Info />', () => {
|
||||
const Info = withInfo('Test Info')(story);
|
||||
ReactDOM.render(<Info />, document.createElement('div'));
|
||||
});
|
||||
it('should should render with missed info', () => {
|
||||
setDefaults(testOptions);
|
||||
addInfo(null, testContext, { info: story, options: testOptions });
|
||||
});
|
||||
it('should show deprecation warning', () => {
|
||||
const addWithInfo = AddonInfo.addWithInfo.bind(api);
|
||||
addWithInfo('jest', 'test info', story);
|
||||
addWithInfo('jest', story);
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user