mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-23 07:42:10 +00:00
more tests on Button
This commit is contained in:
parent
b661f619f1
commit
304c8d22aa
@ -2,6 +2,9 @@ import React from 'react';
|
|||||||
import { render, screen, fireEvent } from '@testing-library/react';
|
import { render, screen, fireEvent } from '@testing-library/react';
|
||||||
import '@testing-library/jest-dom/extend-expect';
|
import '@testing-library/jest-dom/extend-expect';
|
||||||
import Button from '../Components/Button/Button';
|
import Button from '../Components/Button/Button';
|
||||||
|
import ButtonType from '../Components/Button/ButtonTypes';
|
||||||
|
import ShortcutKey from '../Components/ShortcutKey/ShortcutKey';
|
||||||
|
import Icon from '../Components/Icon/Icon';
|
||||||
|
|
||||||
describe('Button test', () => {
|
describe('Button test', () => {
|
||||||
const handleClick: undefined | (() => void) = jest.fn();
|
const handleClick: undefined | (() => void) = jest.fn();
|
||||||
@ -11,6 +14,9 @@ describe('Button test', () => {
|
|||||||
title="sample title"
|
title="sample title"
|
||||||
disabled={true}
|
disabled={true}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
|
shortcutKey={ShortcutKey.Settings}
|
||||||
|
type={ButtonType.Button}
|
||||||
|
showIconOnRight={false}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
const title: HTMLElement = screen.getByText('sample title');
|
const title: HTMLElement = screen.getByText('sample title');
|
||||||
@ -20,6 +26,14 @@ describe('Button test', () => {
|
|||||||
expect(testId).toBeInTheDocument;
|
expect(testId).toBeInTheDocument;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('it should have type button', () => {
|
||||||
|
expect(testId).toHaveAttribute('type', 'button');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('it should have key shortcut', () => {
|
||||||
|
expect(testId).toHaveTextContent(ShortcutKey.Settings);
|
||||||
|
});
|
||||||
|
|
||||||
test('it should have a title', () => {
|
test('it should have a title', () => {
|
||||||
expect(title).toBeInTheDocument;
|
expect(title).toBeInTheDocument;
|
||||||
});
|
});
|
||||||
@ -28,6 +42,14 @@ describe('Button test', () => {
|
|||||||
expect(testId).toHaveAttribute('disabled');
|
expect(testId).toHaveAttribute('disabled');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('it should have class btn', () => {
|
||||||
|
expect(testId).toHaveClass('btn');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('it should have icon', () => {
|
||||||
|
expect(Icon).toBeInTheDocument;
|
||||||
|
});
|
||||||
|
|
||||||
test('it should handle onClick event', () => {
|
test('it should handle onClick event', () => {
|
||||||
fireEvent.click(testId);
|
fireEvent.click(testId);
|
||||||
expect(handleClick).toBeCalled;
|
expect(handleClick).toBeCalled;
|
||||||
|
Loading…
Reference in New Issue
Block a user