summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ui/package.json1
-rw-r--r--ui/test/components/confirmation.js29
2 files changed, 18 insertions, 12 deletions
diff --git a/ui/package.json b/ui/package.json
index 3398e601..b593f7b1 100644
--- a/ui/package.json
+++ b/ui/package.json
@@ -31,6 +31,7 @@
"react-addons-test-utils": "^15.5.1",
"react-bootstrap": "^0.30.5",
"react-dom": "^15.3.2",
+ "sinon": "^2.3.1",
"style-loader": "^0.13.1",
"webpack": "^1.13.1",
"zxcvbn": "^4.4.0"
diff --git a/ui/test/components/confirmation.js b/ui/test/components/confirmation.js
index a563fb3f..8eebb3ee 100644
--- a/ui/test/components/confirmation.js
+++ b/ui/test/components/confirmation.js
@@ -1,32 +1,35 @@
import React from 'react';
import {shallow} from 'enzyme';
import chaiEnzyme from 'chai-enzyme'
-import Confirmation from '../../app/components/confirmation';
+import sinon from 'sinon'
import chai, { expect } from 'chai'
+import Confirmation from '../../app/components/confirmation';
describe('Confirmation Component', () => {
- const simpleFunction0 = () => {return 0}
- const simpleFunction1 = () => {return 1}
-
it('Passed functionss run on click', () => {
+ const onAcceptFuncTest = sinon.spy();
+ const onCancelFuncTest = sinon.spy();
+
const confirmation = shallow(
<Confirmation
- onAccept={simpleFunction0}
- onCancel={simpleFunction1}
+ onAccept={onAcceptFuncTest}
+ onCancel={onCancelFuncTest}
/>
)
- expect(confirmation.find('Button').get(0).props.onClick()).to.equal(simpleFunction0())
- expect(confirmation.find('Button').get(1).props.onClick()).to.equal(simpleFunction1())
+ confirmation.find('Button').at(0).simulate('click')
+ expect(onAcceptFuncTest.calledOnce).to.equal(true)
+ confirmation.find('Button').at(1).simulate('click')
+ expect(onCancelFuncTest.calledOnce).to.equal(true)
})
it('sets defaults correctly', () => {
const confirmation = shallow(
<Confirmation
- onAccept={simpleFunction0}
- onCancel={simpleFunction1}
+ onAccept={() => {}}
+ onCancel={() => {}}
/>
)
@@ -36,14 +39,16 @@ describe('Confirmation Component', () => {
})
it('overwrites defaults correctly', () => {
+ const onAcceptFuncTest = () => {}
+ const onCancelFuncTest = () => {}
const testTitle = "Test Title"
const testAcceptStr = "Test accept string"
const testCancelStr = "Test cancel string"
const confirmation = shallow(
<Confirmation
- onAccept={simpleFunction0}
- onCancel={simpleFunction1}
+ onAccept={() => {}}
+ onCancel={() => {}}
title={testTitle}
acceptStr={testAcceptStr}
cancelStr={testCancelStr}