From 12501bd2dd449ac27c61a25f9b51691839da02f3 Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 20 Aug 2020 17:04:24 -0700 Subject: [PATCH] feat #3 - Fix tests and decrease font size of field label Closes #3 --- src/components/InputField/InputField.test.tsx | 14 +++++++++++--- src/components/InputField/index.tsx | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/InputField/InputField.test.tsx b/src/components/InputField/InputField.test.tsx index 56ee9308..6e089062 100644 --- a/src/components/InputField/InputField.test.tsx +++ b/src/components/InputField/InputField.test.tsx @@ -2,7 +2,7 @@ import { Input } from 'antd' import React from 'react' import Skeleton from 'react-loading-skeleton' import InputField, { InputFieldProps } from './index' -import { mount, ReactWrapper } from 'enzyme' +import { mount, ReactWrapper, shallow } from 'enzyme' let wrapper: ReactWrapper @@ -28,7 +28,15 @@ describe('InputField', () => { }) it('throws an error if value is passed without an onClick', () => { - expect(() => mount()).toThrow() + expect(() => shallow()).toThrow() + }) + + it('should pass onChange and value to the input component if the props exist', () => { + const mockOnChange = jest.fn() + wrapper = mount() + + expect(wrapper.find(Input).props().onChange).toEqual(mockOnChange) + expect(wrapper.find(Input).props().value).toEqual('abc') }) it('correctly passes the disabled prop', () => { @@ -71,7 +79,7 @@ describe('InputField', () => { describe('fullWidth', () => { beforeEach(() => { - // Avoid `attachTo: document.body` Warning + // Mounting to document.body throws a React error, so create a temporary container div for the tests to mount the element to const div = document.createElement('div') div.setAttribute('id', 'container') document.body.appendChild(div) diff --git a/src/components/InputField/index.tsx b/src/components/InputField/index.tsx index dccd4dd7..a21bb494 100644 --- a/src/components/InputField/index.tsx +++ b/src/components/InputField/index.tsx @@ -26,6 +26,7 @@ const useStyles = createUseStyles({ padding: '8.5px 14px' }, label: { + fontSize: '14px', paddingBottom: '5px' }, required: {