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 4, 2019
1 parent 076f79a commit 77c59ce
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 closeIcon = wrapper.find('.close-button div.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' })} />);
console.log(wrapper.debug());
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 div.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 cancelButton = wrapper.find('.close-button');
expect(cancelButton).to.have.length(1);
const closeIcon = cancelButton.find('div.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 77c59ce

Please sign in to comment.