more code coverage

This commit is contained in:
David Lechner
2023-03-08 15:07:16 -06:00
committed by David Lechner
parent 5fa0e90783
commit af160c99a8
28 changed files with 580 additions and 40 deletions
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2023 The Pybricks Authors
import { Toast } from '@blueprintjs/core';
import React from 'react';
import { testRender } from '../../../test';
import { bluetoothNotAvailable } from './BluetoothNotAvailable';
it('should dismiss when close is clicked', async () => {
const callback = jest.fn();
const toast = bluetoothNotAvailable(callback, undefined as never);
const [user, message] = testRender(<Toast {...toast} />);
await user.click(message.getByRole('button', { name: /close/i }));
expect(callback).toHaveBeenCalledWith('dismiss');
});
+18
View File
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2023 The Pybricks Authors
import { Toast } from '@blueprintjs/core';
import React from 'react';
import { testRender } from '../../../test';
import { missingService } from './MissingService';
it('should dismiss when close is clicked', async () => {
const callback = jest.fn();
const toast = missingService(callback, { hubName: 'name', serviceName: 'service' });
const [user, message] = testRender(<Toast {...toast} />);
await user.click(message.getByRole('button', { name: /close/i }));
expect(callback).toHaveBeenCalledWith('dismiss');
});
+18
View File
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2023 The Pybricks Authors
import { Toast } from '@blueprintjs/core';
import React from 'react';
import { testRender } from '../../../test';
import { noGatt } from './NoGatt';
it('should dismiss when close is clicked', async () => {
const callback = jest.fn();
const toast = noGatt(callback, undefined as never);
const [user, message] = testRender(<Toast {...toast} />);
await user.click(message.getByRole('button', { name: /close/i }));
expect(callback).toHaveBeenCalledWith('dismiss');
});
+29
View File
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2023 The Pybricks Authors
import { Toast } from '@blueprintjs/core';
import React from 'react';
import { testRender } from '../../../test';
import { noHub } from './NoHub';
it('should dismiss when close is clicked', async () => {
const callback = jest.fn();
const toast = noHub(callback, undefined as never);
const [user, message] = testRender(<Toast {...toast} />);
await user.click(message.getByRole('button', { name: /close/i }));
expect(callback).toHaveBeenCalledWith('dismiss');
});
it('should flash firmware when button is clicked', async () => {
const callback = jest.fn();
const toast = noHub(callback, undefined as never);
const [user, message] = testRender(<Toast {...toast} />);
await user.click(message.getByRole('button', { name: /firmware/i }));
expect(callback).toHaveBeenCalledWith('flashFirmware');
});
+18
View File
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2023 The Pybricks Authors
import { Toast } from '@blueprintjs/core';
import React from 'react';
import { testRender } from '../../../test';
import { noWebBluetooth } from './NoWebBluetooth';
it('should dismiss when close is clicked', async () => {
const callback = jest.fn();
const toast = noWebBluetooth(callback, undefined as never);
const [user, message] = testRender(<Toast {...toast} />);
await user.click(message.getByRole('button', { name: /close/i }));
expect(callback).toHaveBeenCalledWith('dismiss');
});
+29
View File
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2023 The Pybricks Authors
import { Toast } from '@blueprintjs/core';
import React from 'react';
import { testRender } from '../../../test';
import { oldFirmware } from './OldFirmware';
it('should dismiss when close is clicked', async () => {
const callback = jest.fn();
const toast = oldFirmware(callback, undefined as never);
const [user, message] = testRender(<Toast {...toast} />);
await user.click(message.getByRole('button', { name: /close/i }));
expect(callback).toHaveBeenCalledWith('dismiss');
});
it('should flash firmware when button is clicked', async () => {
const callback = jest.fn();
const toast = oldFirmware(callback, undefined as never);
const [user, message] = testRender(<Toast {...toast} />);
await user.click(message.getByRole('button', { name: /firmware/i }));
expect(callback).toHaveBeenCalledWith('flashFirmware');
});