mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 02:31:49 +08:00
Tests for prop updates
This commit is contained in:
parent
09162b5b77
commit
7e84ed9848
@ -56,4 +56,22 @@ describe("Background Decorator", () => {
|
|||||||
|
|
||||||
expect(spy).toBeCalled();
|
expect(spy).toBeCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should update story on change", () => {
|
||||||
|
const SpiedChannel = new EventEmitter();
|
||||||
|
const nextStory = jest.fn(() => <p>I am next story!</p>);
|
||||||
|
const backgroundDecorator = shallow(<BackgroundDecorator story={testStory} channel={SpiedChannel} />);
|
||||||
|
|
||||||
|
backgroundDecorator.setProps({ story: nextStory });
|
||||||
|
expect(nextStory).toBeCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not update story on other props change", () => {
|
||||||
|
const SpiedChannel = new EventEmitter();
|
||||||
|
const story = jest.fn(() => <p>I am the only one!</p>);
|
||||||
|
const backgroundDecorator = shallow(<BackgroundDecorator story={story} channel={SpiedChannel} />);
|
||||||
|
|
||||||
|
backgroundDecorator.setProps({ randomProp: true });
|
||||||
|
expect(story.mock.calls.length).toBe(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user