-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Torgeir Pedersen Cook
committed
Nov 10, 2016
1 parent
a09b422
commit 6abca33
Showing
7 changed files
with
128 additions
and
119 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
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
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
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
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,33 +1,30 @@ | ||
import React, {PropTypes} from 'react'; | ||
import InfoCircleIcon from 'ffe-icons-react/info-sirkel-ikon'; | ||
import InfoIcon from 'ffe-icons-react/info-ikon'; | ||
import Base from './base'; | ||
|
||
export default function ContextTipMessage({style, children, icon, closeDurationMs, onCloseStart, onCloseEnd}) { | ||
export default function ContextInfoMessage({style, children, header, icon, onClosed}) { | ||
return ( | ||
<Base | ||
messageType='tip' | ||
icon={icon} | ||
header={header} | ||
style={style} | ||
closeDurationMs={closeDurationMs} | ||
onCloseStart={onCloseStart} | ||
onCloseEnd={onCloseEnd} | ||
onCloseed={onClosed} | ||
> | ||
{children} | ||
</Base> | ||
); | ||
} | ||
|
||
ContextTipMessage.propTypes = { | ||
ContextInfoMessage.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
header : PropTypes.string, | ||
style: PropTypes.object, | ||
closeDurationMs: PropTypes.number, | ||
onClosed: PropTypes.func, | ||
}; | ||
|
||
ContextTipMessage.defaultProps = { | ||
icon: <InfoCircleIcon />, | ||
closeDurationMs: 50, | ||
onCloseStart: ()=> { | ||
}, | ||
onCloseEnd: ()=> { | ||
ContextInfoMessage.defaultProps = { | ||
icon: <InfoIcon />, | ||
onClosed: ()=> { | ||
}, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import React, {cloneElement} from 'react'; | ||
import {shallow, mount} from 'enzyme'; | ||
import sinon from 'sinon'; | ||
import { | ||
ContextInfoMessage, | ||
ContextTipMessage, | ||
} from '../'; | ||
import Base from '../base'; | ||
import InfoCircleIcon from 'ffe-icons-react/info-sirkel-ikon'; | ||
|
||
|
||
describe('Test Base', () => { | ||
let wrapper; | ||
let element; | ||
|
||
beforeEach(() => { | ||
element = | ||
<Base | ||
messageType='tip' | ||
icon={<InfoCircleIcon />} | ||
> | ||
<p>content</p> | ||
</Base>; | ||
wrapper = mount( | ||
element | ||
) | ||
}); | ||
|
||
it('renders with provided content', () => { | ||
const content = wrapper.find('.ffe-context-message__content').find('p'); | ||
expect(content.length).to.be(1); | ||
expect(content.text()).to.be('content'); | ||
}); | ||
|
||
it('renders with provided header', () => { | ||
const header = 'header'; | ||
wrapper = mount(cloneElement(element, {header})); | ||
const headerText = wrapper.find('.ffe-context-message__content').find('header'); | ||
expect(headerText.length).to.be(1); | ||
expect(headerText.text()).to.be(header); | ||
}); | ||
|
||
it('renders provided styles to outermost container', () => { | ||
const component = shallow(cloneElement(element, {style: {marginTop: '40px'}})); | ||
expect(component.props().style.marginTop).to.be('40px'); | ||
}); | ||
|
||
it('closes itself after a click on the close button', done => { | ||
const onClickSpy = sinon.spy(); | ||
wrapper = mount(cloneElement(element, {onClosed: onClickSpy})); | ||
wrapper.find('.ffe-context-message__close-button').simulate('click'); | ||
setTimeout(() => { | ||
const component = wrapper.find('.ffe-context-message-wrapper'); | ||
expect(component.get(0).style.getPropertyValue('height')).to.be('0px'); | ||
expect(onClickSpy.calledOnce); | ||
done(); | ||
}, 100); | ||
}); | ||
}); | ||
|
||
describe('Test ContextInfoMessage', () => { | ||
const wrapper = mount( | ||
<ContextInfoMessage | ||
icon={<InfoCircleIcon />} | ||
> | ||
<p>content</p> | ||
</ContextInfoMessage> | ||
); | ||
|
||
it('creates ContextInfoMessage', () => { | ||
const component = wrapper.find('.ffe-context-message-wrapper'); | ||
expect(component.hasClass('ffe-context-message-wrapper--info')).to.be(true); | ||
}); | ||
}); | ||
|
||
describe('Test ContextTipMessage', () => { | ||
const wrapper = mount( | ||
<ContextTipMessage | ||
icon={<InfoCircleIcon />} | ||
> | ||
<p>content</p> | ||
</ContextTipMessage> | ||
); | ||
|
||
it('creates ContextInfoMessage', () => { | ||
const component = wrapper.find('.ffe-context-message-wrapper'); | ||
expect(component.hasClass('ffe-context-message-wrapper--tip')).to.be(true); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.