mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 07:41:58 +08:00
27 lines
862 B
TypeScript
27 lines
862 B
TypeScript
import type { Mock } from 'vitest';
|
|
import { describe, beforeEach, it, expect, vi } from 'vitest';
|
|
import { addons } from 'storybook/internal/preview-api';
|
|
import { EVENTS } from './constants';
|
|
|
|
vi.mock('storybook/internal/preview-api');
|
|
const mockedAddons = vi.mocked(addons);
|
|
|
|
describe('a11yRunner', () => {
|
|
let mockChannel: { on: Mock; emit?: Mock };
|
|
|
|
beforeEach(() => {
|
|
mockedAddons.getChannel.mockReset();
|
|
|
|
mockChannel = { on: vi.fn(), emit: vi.fn() };
|
|
mockedAddons.getChannel.mockReturnValue(mockChannel as any);
|
|
});
|
|
|
|
it('should listen to events', async () => {
|
|
await import('./a11yRunner');
|
|
|
|
expect(mockedAddons.getChannel).toHaveBeenCalled();
|
|
expect(mockChannel.on).toHaveBeenCalledWith(EVENTS.REQUEST, expect.any(Function));
|
|
expect(mockChannel.on).toHaveBeenCalledWith(EVENTS.MANUAL, expect.any(Function));
|
|
});
|
|
});
|