Skip to content

Commit

Permalink
test: action panel button test
Browse files Browse the repository at this point in the history
  • Loading branch information
NamrataTrivedi committed Oct 7, 2019
1 parent 076f79a commit 05b1196
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions src/components/adslot-ui/ActionPanel/index.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,47 @@ describe('ActionPanelComponent', () => {
expect(headerElement).to.have.length(1);
expect(headerElement.find('.title').text()).to.equal('Action Panel');

const closeButton = wrapper.find('.close-button');
expect(closeButton.children().text()).to.equal('');
const closeIcon = closeButton.find('.close-icon');
expect(closeIcon).to.have.length(1);

const bodyElement = wrapper.find('.aui--action-panel-body');
expect(bodyElement).to.have.length(1);

wrapper.instance().componentWillUnmount();
expect(document.body.classList.contains('modal-open')).to.equal(false);
});

it('should render as a modal', () => {
const wrapper = shallow(
<ActionPanel {...makeProps({ isModal: true, size: 'large', actionButton: <Button>Action</Button> })} />
);

it('should render as a modal with close icon', () => {
const wrapper = shallow(<ActionPanel {...makeProps({ isModal: true, size: 'large' })} />);
expect(document.body.classList.contains('modal-open')).to.equal(true);

expect(wrapper.find('.aui--action-panel-modal-wrapper')).to.have.length(1);
const actionPanelElement = wrapper.find('.aui--action-panel');
expect(actionPanelElement.prop('className')).to.equal('aui--action-panel is-large action-modal');

const closeIcon = wrapper.find('.close-button .close-icon');
expect(closeIcon).to.have.length(1);

wrapper.instance().componentWillUnmount();
expect(document.body.classList.contains('modal-open')).to.equal(false);
});

it('should render as a modal with cancel and action buttons', () => {
const wrapper = shallow(
<ActionPanel
{...makeProps({ isModal: true, size: 'large', actionButton: <Button dts="action-button">Action</Button> })}
/>
);
expect(document.body.classList.contains('modal-open')).to.equal(true);
const closeButton = wrapper.find('.close-button');
expect(closeButton.children().text()).to.equal('Cancel');
const closeIcon = closeButton.find('.close-icon');
expect(closeIcon).to.have.length(0);
const actionButton = wrapper.find("[dts='action-button']");
expect(actionButton).to.have.length(1);

wrapper.instance().componentWillUnmount();
expect(document.body.classList.contains('modal-open')).to.equal(false);
});
Expand Down

0 comments on commit 05b1196

Please sign in to comment.