summaryrefslogtreecommitdiff
path: root/ui/test/components/confirmation.js
diff options
context:
space:
mode:
authorSimon Fondrie-Teitler <simonft@riseup.net>2017-05-18 23:20:16 -0400
committerKali Kaneko (leap communications) <kali@leap.se>2017-05-22 13:46:44 +0200
commit6abb5f1449b582f50796c71bbf20d8e4aac2f4de (patch)
treeaa3fd693c58f228ee24eb973e99e9cbd08b9bf41 /ui/test/components/confirmation.js
parenta8f8256c4f9671e4c971498835c443ccff8e9f5f (diff)
[refactor] refactor and add tests for Center and Confirmation
As a couple of initial, example tests, Center and Confirmation were refactored and tests were set up and added with mocha, enzyme and chai. Spinner was also refactored.
Diffstat (limited to 'ui/test/components/confirmation.js')
-rw-r--r--ui/test/components/confirmation.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/ui/test/components/confirmation.js b/ui/test/components/confirmation.js
new file mode 100644
index 0000000..a563fb3
--- /dev/null
+++ b/ui/test/components/confirmation.js
@@ -0,0 +1,57 @@
+import React from 'react';
+import {shallow} from 'enzyme';
+import chaiEnzyme from 'chai-enzyme'
+import Confirmation from '../../app/components/confirmation';
+import chai, { expect } from 'chai'
+
+
+describe('Confirmation Component', () => {
+
+ const simpleFunction0 = () => {return 0}
+ const simpleFunction1 = () => {return 1}
+
+ it('Passed functionss run on click', () => {
+ const confirmation = shallow(
+ <Confirmation
+ onAccept={simpleFunction0}
+ onCancel={simpleFunction1}
+ />
+ )
+
+ expect(confirmation.find('Button').get(0).props.onClick()).to.equal(simpleFunction0())
+ expect(confirmation.find('Button').get(1).props.onClick()).to.equal(simpleFunction1())
+ })
+
+ it('sets defaults correctly', () => {
+ const confirmation = shallow(
+ <Confirmation
+ onAccept={simpleFunction0}
+ onCancel={simpleFunction1}
+ />
+ )
+
+ expect(confirmation.find("ModalTitle").first().children()).to.have.text("Are you sure?")
+ expect(confirmation.find('Button').at(0).children().first()).to.have.text("Accept")
+ expect(confirmation.find('Button').at(1).children().first()).to.have.text("Cancel")
+ })
+
+ it('overwrites defaults correctly', () => {
+ const testTitle = "Test Title"
+ const testAcceptStr = "Test accept string"
+ const testCancelStr = "Test cancel string"
+
+ const confirmation = shallow(
+ <Confirmation
+ onAccept={simpleFunction0}
+ onCancel={simpleFunction1}
+ title={testTitle}
+ acceptStr={testAcceptStr}
+ cancelStr={testCancelStr}
+ />
+ )
+
+ expect(confirmation.find("ModalTitle").first().children()).to.have.text(testTitle)
+ expect(confirmation.find('Button').at(0).children().first()).to.have.text(testAcceptStr)
+ expect(confirmation.find('Button').at(1).children().first()).to.have.text(testCancelStr)
+ })
+})