This repository has been archived by the owner on May 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
COMPASS-4409: Adds icon click handler to modal status message (#25)
- Loading branch information
Showing
2 changed files
with
72 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 50 additions & 30 deletions
80
packages/hadron-react-components/test/modal-status-message.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,60 @@ | ||
import React from 'react'; | ||
import { expect } from 'chai'; | ||
import { shallow } from 'enzyme'; | ||
import { mount, shallow } from 'enzyme'; | ||
import React from 'react'; | ||
import sinon from 'sinon'; | ||
import { ModalStatusMessage } from '../'; | ||
|
||
describe('<ModalStatusMessage />', () => { | ||
const component = shallow( | ||
<ModalStatusMessage icon="error" message="bad things" type="error" /> | ||
); | ||
const iconColumn = component.find('.col-md-1'); | ||
const messageColumn = component.find('.col-md-11'); | ||
|
||
it('sets the base class', () => { | ||
expect(component.hasClass('modal-status-error')).to.equal(true); | ||
}); | ||
|
||
it('sets the child div', () => { | ||
expect(component.find('.row')).to.have.length(1); | ||
}); | ||
|
||
it('sets the icon column', () => { | ||
expect(iconColumn).to.have.length(1); | ||
context('when just showing some content', () => { | ||
const component = shallow( | ||
<ModalStatusMessage icon="error" message="bad things" type="error" /> | ||
); | ||
const iconColumn = component.find('.col-md-1'); | ||
const messageColumn = component.find('.col-md-11'); | ||
|
||
it('sets the base class', () => { | ||
expect(component.hasClass('modal-status-error')).to.equal(true); | ||
}); | ||
|
||
it('sets the child div', () => { | ||
expect(component.find('.row')).to.have.length(1); | ||
}); | ||
|
||
it('sets the icon column', () => { | ||
expect(iconColumn).to.have.length(1); | ||
}); | ||
|
||
it('sets the message column', () => { | ||
expect(messageColumn).to.have.length(1); | ||
}); | ||
|
||
it('sets the icon', () => { | ||
expect(iconColumn.find('.fa-error')).to.have.length(1); | ||
}); | ||
|
||
it('sets the message paragraph', () => { | ||
expect(messageColumn.find('.modal-status-error-message')).to.have.length(1); | ||
}); | ||
|
||
it('sets the message text', () => { | ||
expect(messageColumn.find('.modal-status-error-message').text()).to.equal('bad things'); | ||
}); | ||
|
||
it('does not show an interactible icon without click handler', () => { | ||
expect(component.find('.modal-status-error-icon-interactible')).not.to.be.present; | ||
}); | ||
}); | ||
|
||
it('sets the message column', () => { | ||
expect(messageColumn).to.have.length(1); | ||
}); | ||
context('when providing an icon clicked handler', () => { | ||
const clickSpy = sinon.spy(); | ||
const component = mount( | ||
<ModalStatusMessage icon="times" message="An Error Occurred..." type="error" onIconClickHandler={clickSpy} /> | ||
); | ||
|
||
it('sets the icon', () => { | ||
expect(iconColumn.find('.fa-error')).to.have.length(1); | ||
}); | ||
|
||
it('sets the message paragraph', () => { | ||
expect(messageColumn.find('.modal-status-error-message')).to.have.length(1); | ||
}); | ||
it('is called when clicked', () => { | ||
component.find('.modal-status-error-icon-interactible').first().simulate('click'); | ||
|
||
it('sets the message text', () => { | ||
expect(messageColumn.find('.modal-status-error-message').text()).to.equal('bad things'); | ||
expect(clickSpy.called).to.be.true; | ||
}); | ||
}); | ||
}); |