Skip to content

Commit

Permalink
web: Fix and adapt some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed May 2, 2024
1 parent a848039 commit e77b83a
Show file tree
Hide file tree
Showing 3 changed files with 252 additions and 38 deletions.
16 changes: 9 additions & 7 deletions web/src/components/storage/BootConfigField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,19 @@ const Button = ({ isBold = false, onClick }) => {
* Allows to select the boot config.
* @component
*
* @param {object} props
* @param {boolean} props.configureBoot
* @param {StorageDevice|undefined} props.bootDevice
* @param {StorageDevice|undefined} props.defaultBootDevice
* @param {StorageDevice[]} props.availableDevices
* @param {boolean} props.isLoading
* @param {(boot: BootConfig) => void} props.onChange
* @typedef {object} BootConfigFieldProps
* @property {boolean} configureBoot
* @property {StorageDevice|undefined} bootDevice
* @property {StorageDevice|undefined} defaultBootDevice
* @property {StorageDevice[]} availableDevices
* @property {boolean} isLoading
* @property {(boot: BootConfig) => void} onChange
*
* @typedef {object} BootConfig
* @property {boolean} configureBoot
* @property {StorageDevice} bootDevice
*
* @param {BootConfigFieldProps} props
*/
export default function BootConfigField({
configureBoot,
Expand Down
9 changes: 8 additions & 1 deletion web/src/components/storage/BootConfigField.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ import { screen, within } from "@testing-library/react";
import { plainRender } from "~/test-utils";
import BootConfigField from "~/components/storage/BootConfigField";

/**
* @typedef {import("~/components/storage/BootConfigField").BootConfigFieldProps} BootConfigFieldProps
* @typedef {import ("~/client/storage").StorageDevice} StorageDevice
*/

/** @type {StorageDevice} */
const sda = {
sid: 59,
description: "A fake disk for testing",
Expand All @@ -48,14 +54,15 @@ const sda = {
udevPaths: ["pci-0000:00-12", "pci-0000:00-12-ata"],
};

/** @type {BootConfigFieldProps} */
let props;

beforeEach(() => {
props = {
configureBoot: false,
bootDevice: undefined,
defaultBootDevice: undefined,
devices: [sda],
availableDevices: [sda],
isLoading: false,
onChange: jest.fn()
};
Expand Down
Loading

0 comments on commit e77b83a

Please sign in to comment.