1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Clean up tests

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2022-05-18 13:53:34 +03:00
parent 3888e46e2f
commit 4d0e841343
3 changed files with 14 additions and 4 deletions

View File

@ -4,6 +4,7 @@ exports[`<UpdateButton/> should render if warning level prop passed 1`] = `
<button <button
class="updateButton" class="updateButton"
data-testid="update-button" data-testid="update-button"
data-warning-level="light"
id="update-lens-button" id="update-lens-button"
> >
Update Update

View File

@ -51,19 +51,27 @@ describe("<UpdateButton/>", () => {
expect(update).toHaveBeenCalled(); expect(update).toHaveBeenCalled();
}); });
it("should have class name with medium warning level", () => { it("should have light warning level", () => {
const { getByTestId } = render(<UpdateButton update={update} warningLevel="light" />);
const button = getByTestId("update-button");
expect(button.dataset.warningLevel).toBe("light");
});
it("should have medium warning level", () => {
const { getByTestId } = render(<UpdateButton update={update} warningLevel="medium" />); const { getByTestId } = render(<UpdateButton update={update} warningLevel="medium" />);
const button = getByTestId("update-button"); const button = getByTestId("update-button");
expect(button.className.toLowerCase().includes("medium")).toBeTruthy(); expect(button.dataset.warningLevel).toBe("medium");
}); });
it("should have class name with high warning level", () => { it("should have high warning level", () => {
const { getByTestId } = render(<UpdateButton update={update} warningLevel="high" />); const { getByTestId } = render(<UpdateButton update={update} warningLevel="high" />);
const button = getByTestId("update-button"); const button = getByTestId("update-button");
expect(button.className.toLowerCase().includes("high")).toBeTruthy(); expect(button.dataset.warningLevel).toBe("high");
}); });
}); });

View File

@ -34,6 +34,7 @@ export function UpdateButton({ warningLevel, update, id }: UpdateButtonProps) {
<> <>
<button <button
data-testid="update-button" data-testid="update-button"
data-warning-level={warningLevel}
id={buttonId} id={buttonId}
className={cssNames(styles.updateButton, { className={cssNames(styles.updateButton, {
[styles.warningHigh]: warningLevel === "high", [styles.warningHigh]: warningLevel === "high",