diff --git a/app/soapbox/features/auth_login/components/__tests__/__snapshots__/captcha-test.js.snap b/app/soapbox/features/auth_login/components/__tests__/__snapshots__/captcha-test.js.snap new file mode 100644 index 000000000..0e6cd2204 --- /dev/null +++ b/app/soapbox/features/auth_login/components/__tests__/__snapshots__/captcha-test.js.snap @@ -0,0 +1,26 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` renders null by default 1`] = `null`; + +exports[` renders correctly 1`] = ` +
+ captcha +
+ +
+
+`; diff --git a/app/soapbox/features/auth_login/components/__tests__/captcha-test.js b/app/soapbox/features/auth_login/components/__tests__/captcha-test.js new file mode 100644 index 000000000..96e9d8b22 --- /dev/null +++ b/app/soapbox/features/auth_login/components/__tests__/captcha-test.js @@ -0,0 +1,31 @@ +import React from 'react'; +import CaptchaField, { NativeCaptchaField } from '../captcha'; +import renderer from 'react-test-renderer'; +import { createComponentWithStore } from 'soapbox/test_helpers'; +import { Map as ImmutableMap } from 'immutable'; + +describe('', () => { + it('renders null by default', () => { + expect(createComponentWithStore( + + ).toJSON()).toMatchSnapshot(); + }); +}); + +describe('', () => { + it('renders correctly', () => { + const captcha = ImmutableMap({ + answer_data: 'QTEyOEdDTQ...', + token: 'CcDExJcv6qqOVw', + type: 'native', + url: 'data:image/png;base64,...', + }); + + expect(renderer.create( + {}} // eslint-disable-line react/jsx-no-bind + /> + ).toJSON()).toMatchSnapshot(); + }); +}); diff --git a/app/soapbox/features/auth_login/components/captcha.js b/app/soapbox/features/auth_login/components/captcha.js index 728b24822..381c5de32 100644 --- a/app/soapbox/features/auth_login/components/captcha.js +++ b/app/soapbox/features/auth_login/components/captcha.js @@ -91,7 +91,7 @@ class CaptchaField extends React.Component { } -const NativeCaptchaField = ({ captcha, onChange }) => ( +export const NativeCaptchaField = ({ captcha, onChange }) => (
captcha { + return renderer.create({children}); +}; + // Testing i18n components // https://formatjs.io/docs/react-intl/testing/#helper-function-2 export const createComponentWithIntl = (children, props = { locale: 'en' }) => {