|
| 1 | +/********************************************************************** |
| 2 | + * Copyright (C) 2024 Red Hat, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + * |
| 16 | + * SPDX-License-Identifier: Apache-2.0 |
| 17 | + ***********************************************************************/ |
| 18 | + |
| 19 | +import '@testing-library/jest-dom/vitest'; |
| 20 | +import { test, expect } from 'vitest'; |
| 21 | +import { render, screen } from '@testing-library/svelte'; |
| 22 | + |
| 23 | +import DropDownMenuItem from './DropDownMenuItem.svelte'; |
| 24 | +import { faCircleUp } from '@fortawesome/free-solid-svg-icons'; |
| 25 | + |
| 26 | +test('Expect custom font icon on the contributed action', async () => { |
| 27 | + render(DropDownMenuItem, { |
| 28 | + title: 'dummy-title', |
| 29 | + icon: 'podman-desktop-icon-dummyIcon', |
| 30 | + }); |
| 31 | + |
| 32 | + const iconItem = screen.getByRole('img', { name: 'dummy-title' }); |
| 33 | + expect(iconItem).toBeInTheDocument(); |
| 34 | + // expect to have the podman desktop icon class |
| 35 | + expect(iconItem).toHaveClass('podman-desktop-icon-dummyIcon'); |
| 36 | +}); |
| 37 | + |
| 38 | +test('Expect Font Awesome icon on the contributed action', async () => { |
| 39 | + render(DropDownMenuItem, { |
| 40 | + title: 'dummy-title', |
| 41 | + icon: faCircleUp, |
| 42 | + }); |
| 43 | + |
| 44 | + // grab the svg element |
| 45 | + const svgElement = screen.getByRole('img', { hidden: true }); |
| 46 | + expect(svgElement).toBeInTheDocument(); |
| 47 | + |
| 48 | + // check it is a svelte-fa class |
| 49 | + expect(svgElement).toHaveClass('svelte-fa'); |
| 50 | +}); |
0 commit comments