mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add VerticalBar tests
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
4fdb46f30c
commit
a3d8e44778
30
src/renderer/components/VerticalBar/vertical-bar.test.tsx
Normal file
30
src/renderer/components/VerticalBar/vertical-bar.test.tsx
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React from "react";
|
||||||
|
import { render } from "@testing-library/react";
|
||||||
|
import "@testing-library/jest-dom/extend-expect";
|
||||||
|
import { VerticalBar } from ".";
|
||||||
|
|
||||||
|
describe("<VerticalBar/>", () => {
|
||||||
|
it("renders <VerticalBar /> w/o errors", async () => {
|
||||||
|
|
||||||
|
const { container } = render(<VerticalBar color="red" value={50} />);
|
||||||
|
|
||||||
|
expect(container.querySelector("[data-testid='vertical-bar']")).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("bar uses provided color", () => {
|
||||||
|
const { container } = render(<VerticalBar color="red" value={50} />);
|
||||||
|
|
||||||
|
expect(container.querySelector("[data-testid='vertical-bar'] div")).toHaveStyle("background-color: red");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("bar uses provided value", () => {
|
||||||
|
const { container } = render(<VerticalBar color="red" value={50} />);
|
||||||
|
|
||||||
|
expect(container.querySelector("[data-testid='vertical-bar'] div")).toHaveStyle("height: 50%");
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -15,7 +15,7 @@ interface BarProps extends HTMLAttributes<HTMLDivElement> {
|
|||||||
|
|
||||||
export function VerticalBar({ color, className, value }: BarProps) {
|
export function VerticalBar({ color, className, value }: BarProps) {
|
||||||
return (
|
return (
|
||||||
<div className={styles.verticalBar}>
|
<div className={styles.verticalBar} data-testid="vertical-bar">
|
||||||
<div className={cssNames(styles.value, className)} style={{ backgroundColor: color, height: `${value}%` }}></div>
|
<div className={cssNames(styles.value, className)} style={{ backgroundColor: color, height: `${value}%` }}></div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user