diff options
author | Alexander Tseung <alextsg@gmail.com> | 2018-09-20 05:30:52 +0800 |
---|---|---|
committer | Alexander Tseung <alextsg@gmail.com> | 2018-09-20 05:31:10 +0800 |
commit | 2cfdc95eebc3e0a878017090f22e5136cff709a6 (patch) | |
tree | 34ba4eee9afad4c92d748f76f76b50a0ae96a113 /ui/app/components/modal/modal-content | |
parent | 77e8eac4b380b35f4ab2e6abd82fe929ec7f7c1b (diff) | |
download | tangerine-wallet-browser-2cfdc95eebc3e0a878017090f22e5136cff709a6.tar tangerine-wallet-browser-2cfdc95eebc3e0a878017090f22e5136cff709a6.tar.gz tangerine-wallet-browser-2cfdc95eebc3e0a878017090f22e5136cff709a6.tar.bz2 tangerine-wallet-browser-2cfdc95eebc3e0a878017090f22e5136cff709a6.tar.lz tangerine-wallet-browser-2cfdc95eebc3e0a878017090f22e5136cff709a6.tar.xz tangerine-wallet-browser-2cfdc95eebc3e0a878017090f22e5136cff709a6.tar.zst tangerine-wallet-browser-2cfdc95eebc3e0a878017090f22e5136cff709a6.zip |
Add unit tests
Diffstat (limited to 'ui/app/components/modal/modal-content')
-rw-r--r-- | ui/app/components/modal/modal-content/modal-content.component.js | 20 | ||||
-rw-r--r-- | ui/app/components/modal/modal-content/tests/modal-content.component.test.js | 44 |
2 files changed, 58 insertions, 6 deletions
diff --git a/ui/app/components/modal/modal-content/modal-content.component.js b/ui/app/components/modal/modal-content/modal-content.component.js index 8beb854e0..ecec0ee5b 100644 --- a/ui/app/components/modal/modal-content/modal-content.component.js +++ b/ui/app/components/modal/modal-content/modal-content.component.js @@ -12,12 +12,20 @@ export default class ModalContent extends PureComponent { return ( <div className="modal-content"> - <div className="modal-content__title"> - { title } - </div> - <div className="modal-content__description"> - { description } - </div> + { + title && ( + <div className="modal-content__title"> + { title } + </div> + ) + } + { + description && ( + <div className="modal-content__description"> + { description } + </div> + ) + } </div> ) } diff --git a/ui/app/components/modal/modal-content/tests/modal-content.component.test.js b/ui/app/components/modal/modal-content/tests/modal-content.component.test.js new file mode 100644 index 000000000..17af09f45 --- /dev/null +++ b/ui/app/components/modal/modal-content/tests/modal-content.component.test.js @@ -0,0 +1,44 @@ +import React from 'react' +import assert from 'assert' +import { shallow } from 'enzyme' +import ModalContent from '../modal-content.component' + +describe('ModalContent Component', () => { + it('should render a title', () => { + const wrapper = shallow( + <ModalContent + title="Modal Title" + /> + ) + + assert.equal(wrapper.find('.modal-content__title').length, 1) + assert.equal(wrapper.find('.modal-content__title').text(), 'Modal Title') + assert.equal(wrapper.find('.modal-content__description').length, 0) + }) + + it('should render a description', () => { + const wrapper = shallow( + <ModalContent + description="Modal Description" + /> + ) + + assert.equal(wrapper.find('.modal-content__title').length, 0) + assert.equal(wrapper.find('.modal-content__description').length, 1) + assert.equal(wrapper.find('.modal-content__description').text(), 'Modal Description') + }) + + it('should render both a title and a description', () => { + const wrapper = shallow( + <ModalContent + title="Modal Title" + description="Modal Description" + /> + ) + + assert.equal(wrapper.find('.modal-content__title').length, 1) + assert.equal(wrapper.find('.modal-content__title').text(), 'Modal Title') + assert.equal(wrapper.find('.modal-content__description').length, 1) + assert.equal(wrapper.find('.modal-content__description').text(), 'Modal Description') + }) +}) |