From 0df29192b4f4418a80dc3f514e2aec192b659d49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Tue, 10 Oct 2023 09:01:17 +0200 Subject: [PATCH] Fixed spell check, added unit test --- web/cspell.json | 2 + web/src/components/software/UsedSize.test.jsx | 50 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 web/src/components/software/UsedSize.test.jsx diff --git a/web/cspell.json b/web/cspell.json index 99d2381560..33f8c76794 100644 --- a/web/cspell.json +++ b/web/cspell.json @@ -26,6 +26,7 @@ "chzdev", "dasd", "dasds", + "devel", "dbus", "EspaƱa", "filecontent", @@ -46,6 +47,7 @@ "mgmt", "mmcblk", "multipath", + "multiuser", "ngettext", "onboot", "partitioner", diff --git a/web/src/components/software/UsedSize.test.jsx b/web/src/components/software/UsedSize.test.jsx new file mode 100644 index 0000000000..495efe69f1 --- /dev/null +++ b/web/src/components/software/UsedSize.test.jsx @@ -0,0 +1,50 @@ +/* + * Copyright (c) [2023] SUSE LLC + * + * All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, contact SUSE LLC. + * + * To contact SUSE LLC about this file by physical or electronic mail, you may + * find current contact information at www.suse.com. + */ + +import React from "react"; +import { screen, logDOM } from "@testing-library/react"; +import { plainRender } from "~/test-utils"; + +import UsedSize from "./UsedSize"; + +describe("UsedSize", () => { + it("returns empty component when the size is undefined", () => { + const { container } = plainRender(); + expect(container).toBeEmptyDOMElement(); + }); + + it("returns empty component when the size is empty string", () => { + const { container } = plainRender(); + expect(container).toBeEmptyDOMElement(); + }); + + it("returns empty component when the size is zero", () => { + const { container } = plainRender(); + expect(container).toBeEmptyDOMElement(); + }); + + it("returns summary text with the size", () => { + const size = "1.4 GiB"; + plainRender(); + + screen.getByText(size); + }); +});