mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-15 02:54:07 +00:00
30 lines
876 B
TypeScript
30 lines
876 B
TypeScript
// SPDX-License-Identifier: MIT
|
|
// Copyright (c) 2022-2023 The Pybricks Authors
|
|
|
|
import { act, cleanup } from '@testing-library/react';
|
|
import React from 'react';
|
|
import { FocusScope } from 'react-aria';
|
|
import { testRender } from '../../../../test';
|
|
import { hubStopUserProgram } from '../../../hub/actions';
|
|
import { HubRuntimeState } from '../../../hub/reducers';
|
|
import StopButton from './StopButton';
|
|
|
|
afterEach(() => {
|
|
cleanup();
|
|
});
|
|
|
|
it('should dispatch action when clicked', async () => {
|
|
const [user, button, dispatch] = testRender(
|
|
<FocusScope>
|
|
<StopButton id="test-stop-button" />
|
|
</FocusScope>,
|
|
{
|
|
hub: { runtime: HubRuntimeState.Running },
|
|
},
|
|
);
|
|
|
|
await act(() => user.click(button.getByRole('button', { name: 'Stop' })));
|
|
|
|
expect(dispatch).toHaveBeenCalledWith(hubStopUserProgram());
|
|
});
|