mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-14 10:35:11 +00:00
test: extend testRender to return spy on dispatch
This commit is contained in:
@@ -10,7 +10,7 @@ import AboutDialog from './AboutDialog';
|
||||
it('should close when the button is clicked', () => {
|
||||
const close = jest.fn();
|
||||
|
||||
const dialog = testRender(<AboutDialog isOpen={true} onClose={() => close()} />);
|
||||
const [dialog] = testRender(<AboutDialog isOpen={true} onClose={() => close()} />);
|
||||
|
||||
userEvent.click(dialog.getByLabelText('Close'));
|
||||
|
||||
@@ -18,7 +18,9 @@ it('should close when the button is clicked', () => {
|
||||
});
|
||||
|
||||
it('should manage license dialog open/close', async () => {
|
||||
const dialog = testRender(<AboutDialog isOpen={true} onClose={() => undefined} />);
|
||||
const [dialog] = testRender(
|
||||
<AboutDialog isOpen={true} onClose={() => undefined} />,
|
||||
);
|
||||
|
||||
userEvent.click(dialog.getByText('Software Licenses'));
|
||||
|
||||
|
||||
@@ -19,14 +19,14 @@ function getTextArea(editor: RenderResult): HTMLTextAreaElement {
|
||||
}
|
||||
|
||||
it('should focus the text area', () => {
|
||||
const editor = testRender(<Editor />);
|
||||
const [editor] = testRender(<Editor />);
|
||||
|
||||
expect(getTextArea(editor)).toHaveFocus();
|
||||
});
|
||||
|
||||
describe('context menu', () => {
|
||||
it('should show the context menu', async () => {
|
||||
const editor = testRender(<Editor />);
|
||||
const [editor] = testRender(<Editor />);
|
||||
|
||||
fireEvent.contextMenu(editor.getByText('Write your program here...'));
|
||||
|
||||
@@ -36,7 +36,7 @@ describe('context menu', () => {
|
||||
});
|
||||
|
||||
it('should hide the context menu when Escape is pressed', async () => {
|
||||
const editor = testRender(<Editor />);
|
||||
const [editor] = testRender(<Editor />);
|
||||
|
||||
fireEvent.contextMenu(editor.getByText('Write your program here...'));
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import Explorer from './Explorer';
|
||||
|
||||
describe('archive button', () => {
|
||||
it('should be enabled if there are files', () => {
|
||||
const explorer = testRender(<Explorer />, {
|
||||
const [explorer] = testRender(<Explorer />, {
|
||||
fileStorage: { fileNames: ['test.file'] },
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@ describe('archive button', () => {
|
||||
});
|
||||
|
||||
it('should be disabled if there are no files', () => {
|
||||
const explorer = testRender(<Explorer />, {
|
||||
const [explorer] = testRender(<Explorer />, {
|
||||
fileStorage: { fileNames: [] },
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@ describe('archive button', () => {
|
||||
|
||||
describe('list item', () => {
|
||||
it('should show/hide buttons on hover', () => {
|
||||
const explorer = testRender(<Explorer />, {
|
||||
const [explorer] = testRender(<Explorer />, {
|
||||
fileStorage: { fileNames: ['test.file'] },
|
||||
});
|
||||
|
||||
@@ -45,7 +45,7 @@ describe('list item', () => {
|
||||
});
|
||||
|
||||
it('should not focus buttons on click', () => {
|
||||
const explorer = testRender(<Explorer />, {
|
||||
const [explorer] = testRender(<Explorer />, {
|
||||
fileStorage: { fileNames: ['test.file'] },
|
||||
});
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import { BleConnectionState } from '../ble/reducers';
|
||||
import StatusBar from './StatusBar';
|
||||
|
||||
it('should prevent browser context menu', () => {
|
||||
const statusBar = testRender(<StatusBar />, {
|
||||
const [statusBar] = testRender(<StatusBar />, {
|
||||
ble: { connection: BleConnectionState.Disconnected, deviceName: '' },
|
||||
});
|
||||
|
||||
@@ -19,7 +19,7 @@ it('should prevent browser context menu', () => {
|
||||
it('should show popover when hub name is clicked', async () => {
|
||||
const testHubName = 'Test hub';
|
||||
|
||||
const statusBar = testRender(<StatusBar />, {
|
||||
const [statusBar] = testRender(<StatusBar />, {
|
||||
ble: {
|
||||
connection: BleConnectionState.Connected,
|
||||
deviceName: testHubName,
|
||||
@@ -38,7 +38,7 @@ it('should show popover when hub name is clicked', async () => {
|
||||
it('should show popover when battery is clicked', async () => {
|
||||
const testHubName = 'Test hub';
|
||||
|
||||
const statusBar = testRender(<StatusBar />, {
|
||||
const [statusBar] = testRender(<StatusBar />, {
|
||||
ble: {
|
||||
connection: BleConnectionState.Connected,
|
||||
deviceName: testHubName,
|
||||
|
||||
Reference in New Issue
Block a user