summaryrefslogtreecommitdiff
path: root/ui/test/components
diff options
context:
space:
mode:
Diffstat (limited to 'ui/test/components')
-rw-r--r--ui/test/components/center.js43
-rw-r--r--ui/test/components/confirmation.js57
2 files changed, 100 insertions, 0 deletions
diff --git a/ui/test/components/center.js b/ui/test/components/center.js
new file mode 100644
index 00000000..e9242e7d
--- /dev/null
+++ b/ui/test/components/center.js
@@ -0,0 +1,43 @@
+import React from 'react';
+import {shallow} from 'enzyme';
+import chaiEnzyme from 'chai-enzyme'
+import chai, { expect } from 'chai'
+import Center from '../../app/components/center';
+
+
+describe('Center Component', () => {
+
+ chai.use(chaiEnzyme())
+
+ it('has reasonable defaults', () => {
+ const center = shallow(
+ <Center>
+ test
+ </Center>
+ )
+
+ expect(center.hasClass("center-both"))
+
+ expect(center.find(".center-item")).to.not.have.style('width')
+ })
+
+ it('has a width parameter on the inner div', () => {
+ const center = shallow(
+ <Center width="10">
+ test
+ </Center>
+ )
+
+ expect(center.find(".center-item")).to.have.style('width').equal('10px')
+ })
+
+ it('sets direction parameter in the class name', () => {
+ const center = shallow(
+ <Center direction="vertically">
+ test
+ </Center>
+ )
+
+ expect(center).to.have.className("center-vertically")
+ })
+})
diff --git a/ui/test/components/confirmation.js b/ui/test/components/confirmation.js
new file mode 100644
index 00000000..a563fb3f
--- /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)
+ })
+})