aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/error-message
diff options
context:
space:
mode:
authorAlexander Tseung <alextsg@gmail.com>2018-09-20 05:30:52 +0800
committerAlexander Tseung <alextsg@gmail.com>2018-09-20 05:31:10 +0800
commit2cfdc95eebc3e0a878017090f22e5136cff709a6 (patch)
tree34ba4eee9afad4c92d748f76f76b50a0ae96a113 /ui/app/components/error-message
parent77e8eac4b380b35f4ab2e6abd82fe929ec7f7c1b (diff)
downloadtangerine-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/error-message')
-rw-r--r--ui/app/components/error-message/tests/error-message.component.test.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/ui/app/components/error-message/tests/error-message.component.test.js b/ui/app/components/error-message/tests/error-message.component.test.js
new file mode 100644
index 000000000..8c5347173
--- /dev/null
+++ b/ui/app/components/error-message/tests/error-message.component.test.js
@@ -0,0 +1,36 @@
+import React from 'react'
+import assert from 'assert'
+import { shallow } from 'enzyme'
+import ErrorMessage from '../error-message.component'
+
+describe('ErrorMessage Component', () => {
+ const t = key => `translate ${key}`
+
+ it('should render a message from props.errorMessage', () => {
+ const wrapper = shallow(
+ <ErrorMessage
+ errorMessage="This is an error."
+ />,
+ { context: { t }}
+ )
+
+ assert.ok(wrapper)
+ assert.equal(wrapper.find('.error-message').length, 1)
+ assert.equal(wrapper.find('.error-message__icon').length, 1)
+ assert.equal(wrapper.find('.error-message__text').text(), 'ALERT: This is an error.')
+ })
+
+ it('should render a message translated from props.errorKey', () => {
+ const wrapper = shallow(
+ <ErrorMessage
+ errorKey="testKey"
+ />,
+ { context: { t }}
+ )
+
+ assert.ok(wrapper)
+ assert.equal(wrapper.find('.error-message').length, 1)
+ assert.equal(wrapper.find('.error-message__icon').length, 1)
+ assert.equal(wrapper.find('.error-message__text').text(), 'ALERT: translate testKey')
+ })
+})