2019-07-26 14:45:24 +08:00

23 lines
702 B
JavaScript

import React from 'react';
import { render, fireEvent } from 'react-testing-library';
import { withText as WithText, withCounter as WithCounter } from './button.stories';
const mockAction = jest.fn();
jest.mock('@storybook/addon-actions', () => ({
action: () => mockAction,
}));
describe('module story embedding', () => {
it('should test actions', () => {
const comp = render(<WithText />);
fireEvent.click(comp.getByText('Hello Button'));
expect(mockAction).toHaveBeenCalled();
});
it('should test story state', () => {
const comp = render(<WithCounter />);
fireEvent.click(comp.getByText('Testing: 0'));
expect(comp.getByText('Testing: 1')).toBeTruthy();
});
});