2021-06-29 04:03:36 -05:00
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
//
|
2024-01-01 02:43:48 -06:00
|
|
|
// Copyright (C) 2013 - 2024, The pgAdmin Development Team
|
2021-06-29 04:03:36 -05:00
|
|
|
// This software is released under the PostgreSQL Licence
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
import React from 'react';
|
2023-10-23 07:13:17 -05:00
|
|
|
|
2021-06-29 04:03:36 -05:00
|
|
|
import { withTheme } from '../fake_theme';
|
|
|
|
import InfoIcon from '@material-ui/icons/InfoRounded';
|
|
|
|
|
|
|
|
import {PrimaryButton, DefaultButton, PgIconButton} from 'sources/components/Buttons';
|
2023-10-23 07:13:17 -05:00
|
|
|
import { render, screen } from '@testing-library/react';
|
2021-06-29 04:03:36 -05:00
|
|
|
|
|
|
|
/* MUI Components need to be wrapped in Theme for theme vars */
|
|
|
|
describe('components Buttons', ()=>{
|
|
|
|
it('PrimaryButton', ()=>{
|
|
|
|
let ThemedBtn = withTheme(PrimaryButton);
|
2023-10-23 07:13:17 -05:00
|
|
|
render(<ThemedBtn>Test</ThemedBtn>);
|
|
|
|
expect(screen.getByRole('button').classList.contains('MuiButton-containedPrimary')).toBe(true);
|
2021-06-29 04:03:36 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('DefaultButton', ()=>{
|
|
|
|
let ThemedBtn = withTheme(DefaultButton);
|
2023-10-23 07:13:17 -05:00
|
|
|
render(<ThemedBtn className="testClass">Test</ThemedBtn>);
|
|
|
|
const btn = screen.getByRole('button');
|
|
|
|
expect(btn.classList.contains('MuiButton-outlined')).toBe(true);
|
|
|
|
expect(btn.classList.contains('testClass')).toBe(true);
|
2021-06-29 04:03:36 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('PgIconButton', ()=>{
|
2023-10-23 07:13:17 -05:00
|
|
|
let Icon = <InfoIcon data-testid="info-icon" />;
|
2021-06-29 04:03:36 -05:00
|
|
|
let ThemedBtn = withTheme(PgIconButton);
|
2023-10-23 07:13:17 -05:00
|
|
|
render(<ThemedBtn title="The icon button" icon={Icon} className="testClass"></ThemedBtn>);
|
|
|
|
expect(screen.getByTestId('info-icon')).not.toBe(null);
|
2021-06-29 04:03:36 -05:00
|
|
|
});
|
|
|
|
});
|