Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import uuidV1 from 'uuid/v1';
import React from 'react';
import PropTypes from 'prop-types';
import { Button } from 'patternfly-react';
import { Button } from '@patternfly/react-core';
import { translate as __ } from '../../../../common/I18n';

const DeleteButton = ({ active, onClick }) =>
active ? (
<Button bsStyle="default" onClick={onClick}>
<Button ouiaId={`table-delete-button-${uuidV1()}`} variant="secondary" onClick={onClick}>

Check failure on line 9 in webpack/assets/javascripts/react_app/components/common/table/components/DeleteButton.js

View workflow job for this annotation

GitHub Actions / test (13, 3.0, 18)

Replace `·ouiaId={`table-delete-button-${uuidV1()}`}·variant="secondary"·onClick={onClick}` with `⏎······ouiaId={`table-delete-button-${uuidV1()}`}⏎······variant="secondary"⏎······onClick={onClick}⏎····`

Check failure on line 9 in webpack/assets/javascripts/react_app/components/common/table/components/DeleteButton.js

View workflow job for this annotation

GitHub Actions / test (13, 3.0, 22)

Replace `·ouiaId={`table-delete-button-${uuidV1()}`}·variant="secondary"·onClick={onClick}` with `⏎······ouiaId={`table-delete-button-${uuidV1()}`}⏎······variant="secondary"⏎······onClick={onClick}⏎····`
{__('Delete')}
</Button>
) : null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { testComponentSnapshotsWithFixtures } from 'foremanReact/common/testHelpers';
import React from 'react';
import { screen, fireEvent, render, act } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';

import DeleteButton from '../DeleteButton';

const baseProps = {
Expand All @@ -9,13 +12,49 @@ const baseProps = {
};

const fixtures = {
'should render delete button on active': {
active: {
active: true,
...baseProps,
},
'should render nothing on inactive': baseProps,
inactive: baseProps,
};

describe('DeleteButton', () => {
testComponentSnapshotsWithFixtures(DeleteButton, fixtures);
describe('when active', () => {
const props = { ...fixtures.active };

it('should render delete button', () => {
render(<DeleteButton {...props} />);

const deleteButton = screen.getByRole('button', { name: /delete/i });
expect(deleteButton).toBeInTheDocument();
});

it('should have correct button text', () => {
render(<DeleteButton {...props} />);

const deleteButton = screen.getByRole('button', { name: /delete/i });
expect(deleteButton).toHaveTextContent('Delete');
});

it('should have secondary variant style', () => {
render(<DeleteButton {...props} />);

const deleteButton = screen.getByRole('button', { name: /delete/i });
expect(deleteButton).toHaveClass('pf-m-secondary');
});
});

describe('when inactive', () => {
const props = { ...fixtures.inactive };

it('should not render anything', () => {
const { container } = render(<DeleteButton {...props} />);

const button = screen.queryByRole('button', { name: /delete/i });
expect(button).not.toBeInTheDocument();

expect(container.firstChild).toBeNull();
});
});
});

This file was deleted.

Loading