Sha256: 0f6292358d83a28b2ddaeb7139ccfaae6feb3acd84a87a2b67e261b3fd9f79db

Contents?: true

Size: 1.66 KB

Versions: 25

Compression:

Stored size: 1.66 KB

Contents

import React from 'react';
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import { Button } from 'patternfly-react';
import Dialog from '../Dialog';

describe('Dialog', () => {
  const props = {
    show: true,
    onCancel: () => {},
    title: 'Message dialog',
  };
  const message = 'Some important message';

  it('renders a message dialog', async () => {
    const dialog = shallow(<Dialog
      {...props}
      {...{ message }}
    />);
    expect(toJson(dialog)).toMatchSnapshot();
  });

  it('enables to override cancel button label', async () => {
    const dialog = shallow(<Dialog
      {...props}
      {...{ message }}
      cancelLabel="Custom cancel"
    />);
    expect(toJson(dialog)).toMatchSnapshot();
  });

  it('enables to set inner html', async () => {
    const dialog = shallow(<Dialog
      {...props}
      dangerouslySetInnerHTML={{ _html: '<b>Custom</b> html content' }}
    />);
    expect(toJson(dialog)).toMatchSnapshot();
  });

  it("passes onCancel to the default OK button's onClick", () => {
    const onCancel = jest.fn();
    const dialog = shallow(<Dialog
      {...props}
      {...{ onCancel }}
    />);
    expect(dialog.find('ModalFooter > Button[bsStyle="default"]').props().onClick).toBe(onCancel);
    expect(dialog.find('ModalHeader > Button').props().onClick).toBe(onCancel);
  });

  it('enables to define custom buttons', async () => {
    const dialog = shallow(<Dialog
      {...props}
      buttons={[
        <Button key="btn1">Button 1</Button>,
        <Button key="btn2">Button 2</Button>,
        <Button key="btn3">Button 3</Button>,
      ]}
    />);
    expect(toJson(dialog)).toMatchSnapshot();
  });
});

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
katello-3.11.2 webpack/move_to_foreman/components/common/Dialog/__tests__/Dialog.test.js
katello-3.10.2 webpack/move_to_foreman/components/common/Dialog/__tests__/Dialog.test.js
katello-3.10.1.1 webpack/move_to_foreman/components/common/Dialog/__tests__/Dialog.test.js
katello-3.10.1 webpack/move_to_foreman/components/common/Dialog/__tests__/Dialog.test.js
katello-3.11.1 webpack/move_to_foreman/components/common/Dialog/__tests__/Dialog.test.js
katello-3.11.0 webpack/move_to_foreman/components/common/Dialog/__tests__/Dialog.test.js
katello-3.11.0.rc2 webpack/move_to_foreman/components/common/Dialog/__tests__/Dialog.test.js
katello-3.11.0.rc1 webpack/move_to_foreman/components/common/Dialog/__tests__/Dialog.test.js
katello-3.10.0 webpack/move_to_foreman/components/common/Dialog/__tests__/Dialog.test.js
katello-3.10.0.rc1.1 webpack/move_to_foreman/components/common/Dialog/__tests__/Dialog.test.js
katello-3.9.1 webpack/move_to_foreman/components/common/Dialog/__tests__/Dialog.test.js
katello-3.10.0.rc1 webpack/move_to_foreman/components/common/Dialog/__tests__/Dialog.test.js
katello-3.9.0 webpack/move_to_foreman/components/common/Dialog/__tests__/Dialog.test.js
katello-3.8.1 webpack/move_to_foreman/components/common/Dialog/__tests__/Dialog.test.js
katello-3.9.0.rc2 webpack/move_to_foreman/components/common/Dialog/__tests__/Dialog.test.js
katello-3.9.0.rc1 webpack/move_to_foreman/components/common/Dialog/__tests__/Dialog.test.js
katello-3.7.1.1 webpack/move_to_foreman/components/common/Dialog/__tests__/Dialog.test.js
katello-3.7.1 webpack/move_to_foreman/components/common/Dialog/__tests__/Dialog.test.js
katello-3.8.0 webpack/move_to_foreman/components/common/Dialog/__tests__/Dialog.test.js
katello-3.8.0.rc3 webpack/move_to_foreman/components/common/Dialog/__tests__/Dialog.test.js