mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-14 18:46:17 +00:00
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
// SPDX-License-Identifier: MIT
|
|
// Copyright (c) 2021-2022 The Pybricks Authors
|
|
|
|
import { waitFor } from '@testing-library/react';
|
|
import React from 'react';
|
|
import { testRender } from '../../test';
|
|
import { BleConnectionState } from '../ble/reducers';
|
|
import StatusBar from './StatusBar';
|
|
|
|
it('should show popover when hub name is clicked', async () => {
|
|
const testHubName = 'Test hub';
|
|
|
|
const [user, statusBar] = testRender(<StatusBar />, {
|
|
ble: {
|
|
connection: BleConnectionState.Connected,
|
|
deviceName: testHubName,
|
|
deviceType: 'hub type',
|
|
deviceFirmwareVersion: 'v0.0.0',
|
|
deviceLowBatteryWarning: false,
|
|
deviceBatteryCharging: false,
|
|
},
|
|
});
|
|
|
|
await user.click(statusBar.getByText(testHubName));
|
|
|
|
await waitFor(() => statusBar.getByText('Connected to:'));
|
|
});
|
|
|
|
it('should show popover when battery is clicked', async () => {
|
|
const testHubName = 'Test hub';
|
|
|
|
const [user, statusBar] = testRender(<StatusBar />, {
|
|
ble: {
|
|
connection: BleConnectionState.Connected,
|
|
deviceName: testHubName,
|
|
deviceType: 'hub type',
|
|
deviceFirmwareVersion: 'v0.0.0',
|
|
deviceLowBatteryWarning: false,
|
|
deviceBatteryCharging: false,
|
|
},
|
|
});
|
|
|
|
await user.click(statusBar.getByTitle('Battery'));
|
|
|
|
await waitFor(() => statusBar.getByText('Battery level is OK.'));
|
|
});
|