-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
840 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright Contributors to the Packit project. | ||
// SPDX-License-Identifier: MIT | ||
import { assertType, test, vi } from "vitest"; | ||
import { getHostName } from "./forgeUrls"; | ||
|
||
test("can get hostname from string", ({ expect }) => { | ||
expect(getHostName("https://example.com?foo=bar")).toBe("example.com"); | ||
}); | ||
|
||
test("can get hostname from URL instance", ({ expect }) => { | ||
const host = new URL("https://example.com"); | ||
expect(getHostName(host)).toBe("example.com"); | ||
}); | ||
|
||
test("hostname logs error for invalid URL", ({ expect }) => { | ||
const consoleMock = vi | ||
.spyOn(console, "error") | ||
.mockImplementation(() => undefined); | ||
expect(getHostName("invalid url")).toBe(""); | ||
|
||
expect(consoleMock.mock.lastCall?.[0].toString()).toContain("Invalid URL"); | ||
expect(consoleMock.mock.lastCall?.[0]).toBeInstanceOf(TypeError); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
frontend/src/components/statusLabels/BaseStatusLabel.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright Contributors to the Packit project. | ||
// SPDX-License-Identifier: MIT | ||
|
||
import { IceCreamIcon } from "@patternfly/react-icons"; | ||
import { render } from "@testing-library/react"; | ||
import { test } from "vitest"; | ||
import { BaseStatusLabel } from "./BaseStatusLabel"; | ||
|
||
test("default label", async ({ expect }) => { | ||
const { baseElement } = render( | ||
<BaseStatusLabel | ||
color="blue" | ||
tooltipText="tooltipText" | ||
icon={<IceCreamIcon />} | ||
label="Label fsdf" | ||
/>, | ||
); | ||
expect(baseElement).toMatchSnapshot("default label"); | ||
}); |
47 changes: 47 additions & 0 deletions
47
frontend/src/components/statusLabels/__snapshots__/BaseStatusLabel.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`default label > default label 1`] = ` | ||
<body> | ||
<div> | ||
<div | ||
style="display: contents;" | ||
> | ||
<span | ||
style="padding: 2px;" | ||
> | ||
<span | ||
class="pf-v5-c-label pf-m-blue" | ||
> | ||
<span | ||
class="pf-v5-c-label__icon" | ||
> | ||
<svg | ||
aria-hidden="true" | ||
class="pf-v5-svg" | ||
fill="currentColor" | ||
height="1em" | ||
role="img" | ||
viewBox="0 0 448 512" | ||
width="1em" | ||
> | ||
<path | ||
d="M368 160h-.94a144 144 0 1 0-286.12 0H80a48 48 0 0 0 0 96h288a48 48 0 0 0 0-96zM195.38 493.69a31.52 31.52 0 0 0 57.24 0L352 288H96z" | ||
/> | ||
</svg> | ||
</span> | ||
<span | ||
class="pf-v5-c-label__text" | ||
> | ||
Label fsdf | ||
<span | ||
class="pf-v5-u-screen-reader" | ||
> | ||
tooltipText | ||
</span> | ||
</span> | ||
</span> | ||
</span> | ||
</div> | ||
</div> | ||
</body> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.