summaryrefslogtreecommitdiffhomepage
path: root/test/components
diff options
context:
space:
mode:
Diffstat (limited to 'test/components')
-rw-r--r--test/components/Settings.spec.js14
-rw-r--r--test/components/Support.spec.js70
2 files changed, 81 insertions, 3 deletions
diff --git a/test/components/Settings.spec.js b/test/components/Settings.spec.js
index 5655e1e5fa..f90d658f9b 100644
--- a/test/components/Settings.spec.js
+++ b/test/components/Settings.spec.js
@@ -43,8 +43,8 @@ describe('components/Settings', () => {
onQuit: () => {},
onClose: () => {},
onViewAccount: () => {},
- onExternalLink: (_type) => {},
- onUpdateSettings: (_update) => {}
+ onViewSupport: () => {},
+ onExternalLink: (_type) => {}
};
return Object.assign({}, defaultProps, mergeProps);
};
@@ -128,6 +128,14 @@ describe('components/Settings', () => {
Simulate.click(domNode);
});
+ it('should call support callback', (done) => {
+ const props = makeProps(loggedInAccountState, settingsState, {
+ onViewSupport: () => done()
+ });
+ const domNode = ReactTestUtils.findRenderedDOMComponentWithClass(render(props), 'settings__view-support');
+ Simulate.click(domNode);
+ });
+
it('should call external links callback', () => {
let collectedExternalLinkTypes: Array<string> = [];
const props = makeProps(loggedOutAccountState, settingsState, {
@@ -140,7 +148,7 @@ describe('components/Settings', () => {
.filter((elm: HTMLElement) => elm.classList.contains('settings__cell'))
.forEach((elm) => Simulate.click(elm));
- expect(collectedExternalLinkTypes).to.include.ordered.members(['faq', 'guides', 'supportEmail']);
+ expect(collectedExternalLinkTypes).to.include.ordered.members(['faq', 'guides']);
});
});
diff --git a/test/components/Support.spec.js b/test/components/Support.spec.js
new file mode 100644
index 0000000000..bcd871855b
--- /dev/null
+++ b/test/components/Support.spec.js
@@ -0,0 +1,70 @@
+// @flow
+
+import { expect } from 'chai';
+import React from 'react';
+import ReactTestUtils, { Simulate } from 'react-dom/test-utils';
+import Support from '../../app/components/Support';
+
+import type { SupportProps } from '../../app/components/Support';
+
+describe('components/Support', () => {
+
+ const makeProps = (mergeProps: $Shape<SupportProps> = {}): SupportProps => {
+ const defaultProps: SupportProps = {
+ onClose: () => {},
+ onViewLogs: () => {},
+ onSend: (_report) => {}
+ };
+ return Object.assign({}, defaultProps, mergeProps);
+ };
+
+ const render = (props: SupportProps): Support => {
+ return ReactTestUtils.renderIntoDocument(
+ <Support { ...props } />
+ );
+ };
+
+ it('should call close callback', (done) => {
+ const props = makeProps({
+ onClose: () => done()
+ });
+ const domNode = ReactTestUtils.findRenderedDOMComponentWithClass(render(props), 'support__close');
+ Simulate.click(domNode);
+ });
+
+ it('should call view logs callback', (done) => {
+ const props = makeProps({
+ onViewLogs: () => done()
+ });
+ const domNode = ReactTestUtils.findRenderedDOMComponentWithClass(render(props), 'support__form-view-logs');
+ Simulate.click(domNode);
+ });
+
+ it('should call send callback when description filled in', (done) => {
+ const props = makeProps({
+ onSend: (_report) => done()
+ });
+
+ const component = render(props);
+
+ const descriptionField = ReactTestUtils.findRenderedDOMComponentWithClass(component, 'support__form-description');
+ descriptionField.value = 'Lorem Ipsum';
+ Simulate.change(descriptionField);
+
+ const sendButton = ReactTestUtils.findRenderedDOMComponentWithClass(component, 'support__form-send');
+ expect(sendButton.disabled).to.be.false;
+ Simulate.click(sendButton);
+ });
+
+ it('should not call send callback when description is empty', () => {
+ const component = render(makeProps());
+
+ const descriptionField = ReactTestUtils.findRenderedDOMComponentWithClass(component, 'support__form-description');
+ descriptionField.value = '';
+ Simulate.change(descriptionField);
+
+ const sendButton = ReactTestUtils.findRenderedDOMComponentWithClass(component, 'support__form-send');
+ expect(sendButton.disabled).to.be.true;
+ });
+
+});