diff --git a/src/components/Form/__snapshots__/test.js.snap b/src/components/Form/__snapshots__/test.js.snap
index dc165f3..96f31ec 100644
--- a/src/components/Form/__snapshots__/test.js.snap
+++ b/src/components/Form/__snapshots__/test.js.snap
@@ -44,3 +44,129 @@ exports[`Form rendering 1`] = `
`;
+
+exports[`Form rendering with download URLs 1`] = `
+
+`;
+
+exports[`Form rendering with permalink URL 1`] = `
+
+
+
+`;
diff --git a/src/components/Form/test.js b/src/components/Form/test.js
index 248b3e6..89f245b 100644
--- a/src/components/Form/test.js
+++ b/src/components/Form/test.js
@@ -1,5 +1,5 @@
import React from 'react';
-import { shallow } from 'enzyme';
+import { shallow, mount } from 'enzyme';
import { Form } from 'components/Form';
import { translate, I18nWrapper } from '__mocks__/i18n';
@@ -17,11 +17,67 @@ describe('Form', () => {
expect(component).toMatchSnapshot();
});
- test('rendering with download URLs');
+ test('rendering with download URLs', () => {
+ const downloadUrls = [
+ { url: '#svg', filename: 'image.svg', type: 'image/svg+xml', label: 'Download SVG' },
+ { url: '#png', filename: 'image.png', type: 'image/png', label: 'Download PNG' }
+ ];
+ const component = shallow(
+
+ );
+ expect(component).toMatchSnapshot();
+ });
- test('rendering with permalink URL');
+ test('rendering with permalink URL', () => {
+ const permalinkUrl = '#permalink';
+ const component = shallow(
+
+ );
+ expect(component).toMatchSnapshot();
+ });
- test('submitting form');
+ describe('submitting expression', () => {
+ const build = (props = {}) => {
+ const component = mount(
+
+
+
+ );
+ return component;
+ };
- test('submitting form with Shift+Enter');
+ test('submitting form', () => {
+ const onSubmit = jest.fn();
+ const component = build({ onSubmit });
+ const eventObj = { preventDefault: jest.fn() };
+ component.find(Form).instance().textarea.value = 'Test textarea value';
+ component.find('form').simulate('submit', eventObj);
+
+ expect(eventObj.preventDefault).toHaveBeenCalled();
+ expect(onSubmit).toHaveBeenCalledWith({
+ expr: 'Test textarea value',
+ syntax: 'js'
+ });
+ });
+
+ test('submitting form with Shift+Enter', () => {
+ const component = build({ onSubmit: Function.prototype });
+ const form = component.find(Form).instance();
+ const eventObj = { charCode: 13, shiftKey: true };
+ jest.spyOn(form, 'handleSubmit');
+ component.find('textarea').simulate('keypress', eventObj);
+
+ expect(form.handleSubmit).toHaveBeenCalled();
+ });
+
+ test('not submitting with just Enter', () => {
+ const component = build({ onSubmit: Function.prototype });
+ const form = component.find(Form).instance();
+ const eventObj = { charCode: 13, shiftKey: false };
+ jest.spyOn(form, 'handleSubmit');
+ component.find('textarea').simulate('keypress', eventObj);
+
+ expect(form.handleSubmit).not.toHaveBeenCalled();
+ });
+ });
});