]> cat aescling's git repositories - mastodon.git/commitdiff
add sinon; add basic Button component test
authorKai Schaper <303@posteo.de>
Mon, 10 Oct 2016 20:44:06 +0000 (22:44 +0200)
committerKai Schaper <303@posteo.de>
Mon, 10 Oct 2016 20:48:58 +0000 (22:48 +0200)
package.json
spec/javascript/components/button.test.jsx [new file with mode: 0644]

index 5d03df01843270592e8dac4079c29b0c08063403..e980a72b2f3b267c189457c7ba5ce1a774f79dbb 100644 (file)
@@ -34,6 +34,7 @@
     "redux": "^3.5.2",
     "redux-immutable": "^3.0.8",
     "redux-thunk": "^2.1.0",
-    "reselect": "^2.5.4"
+    "reselect": "^2.5.4",
+    "sinon": "^1.17.6"
   }
 }
diff --git a/spec/javascript/components/button.test.jsx b/spec/javascript/components/button.test.jsx
new file mode 100644 (file)
index 0000000..5610e67
--- /dev/null
@@ -0,0 +1,14 @@
+import { expect } from 'chai';
+import { shallow } from 'enzyme';
+import sinon from 'sinon';
+
+import Button from '../../../app/assets/javascripts/components/components/button'
+
+describe('<Button />', function() {
+  it('simulates click events', function() {
+    const onClick = sinon.spy();
+    const wrapper = shallow(<Button onClick={onClick} />);
+    wrapper.find('button').simulate('click');
+    expect(onClick.calledOnce).to.equal(true);
+  });
+});