From f6015765fb4988e484483b77b032ea00ebde59c2 Mon Sep 17 00:00:00 2001 From: Darren Eng Date: Fri, 11 Dec 2020 15:20:51 -0800 Subject: [PATCH] feat: remove form-control-file class form-control-file class has been removed in Bootstrap 5 https://getbootstrap.com/docs/5.0/forms/form-control/#file-input https://getbootstrap.com/docs/5.0/migration/#forms-2 --- src/Input.js | 3 --- src/__tests__/Input.spec.js | 19 +++++++------------ 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/Input.js b/src/Input.js index 7c3d058cb..7e44b5f47 100644 --- a/src/Input.js +++ b/src/Input.js @@ -66,7 +66,6 @@ class Input extends React.Component { const checkInput = ['radio', 'checkbox'].indexOf(type) > -1; const isNotaNumber = new RegExp('\\D', 'g'); - const fileInput = type === 'file'; const textareaInput = type === 'textarea'; const selectInput = type === 'select'; const rangeInput = type === 'range'; @@ -77,8 +76,6 @@ class Input extends React.Component { if (plaintext) { formControlClass = `${formControlClass}-plaintext`; Tag = tag || 'input'; - } else if (fileInput) { - formControlClass = `${formControlClass}-file`; } else if (rangeInput) { formControlClass = `${formControlClass}-range`; } else if (selectInput) { diff --git a/src/__tests__/Input.spec.js b/src/__tests__/Input.spec.js index 317312fc5..d47e4da6f 100644 --- a/src/__tests__/Input.spec.js +++ b/src/__tests__/Input.spec.js @@ -157,18 +157,16 @@ describe('Input', () => { expect(wrapper.hasClass('form-control')).toBe(true); }); - it('should not render with "form-control-file" nor "form-control-plaintext" nor "form-check-input" class by default', () => { + it('should not render with "form-control-plaintext" nor "form-check-input" class by default', () => { const wrapper = shallow(); - expect(wrapper.hasClass('form-control-file')).toBe(false); expect(wrapper.hasClass('form-control-plaintext')).toBe(false); expect(wrapper.hasClass('form-check-input')).toBe(false); }); - it('should not render with "form-control" nor "form-control-plaintext" nor "form-check-input" class when type is file', () => { + it('should not render with "form-control-plaintext" nor "form-check-input" class when type is file', () => { const wrapper = shallow(); - expect(wrapper.hasClass('form-control')).toBe(false); expect(wrapper.hasClass('form-control-plaintext')).toBe(false); expect(wrapper.hasClass('form-check-input')).toBe(false); }); @@ -181,25 +179,22 @@ describe('Input', () => { expect(wrapper.hasClass('form-check-input')).toBe(false); }); - it('should not render with "form-control-file" nor "form-control" nor "form-check-input" class when plaintext prop is truthy', () => { + it('should not render with "form-control" nor "form-check-input" class when plaintext prop is truthy', () => { const wrapper = shallow(); - expect(wrapper.hasClass('form-control-file')).toBe(false); expect(wrapper.hasClass('form-control')).toBe(false); expect(wrapper.hasClass('form-check-input')).toBe(false); }); - it('should not render with "form-control-file" nor "form-control-plaintext" nor "form-control" class when type is radio', () => { + it('should not render nor "form-control-plaintext" nor "form-control" class when type is radio', () => { const wrapper = shallow(); - expect(wrapper.hasClass('form-control-file')).toBe(false); expect(wrapper.hasClass('form-control-plaintext')).toBe(false); expect(wrapper.hasClass('form-control')).toBe(false); }); - it('should not render with "form-control-file" nor "form-control-plaintext" nor "form-control" class when type is checkbox', () => { + it('should not render nor "form-control-plaintext" nor "form-control" class when type is checkbox', () => { const wrapper = shallow(); - expect(wrapper.hasClass('form-control-file')).toBe(false); expect(wrapper.hasClass('form-control-plaintext')).toBe(false); expect(wrapper.hasClass('form-control')).toBe(false); }); @@ -236,10 +231,10 @@ describe('Input', () => { expect(wrapper.hasClass('form-select')).toBe(true); }); - it('should render with "form-control-file" class when type is file', () => { + it('should render with "form-control" class when type is file', () => { const wrapper = shallow(); - expect(wrapper.hasClass('form-control-file')).toBe(true); + expect(wrapper.hasClass('form-control')).toBe(true); }); it('should render additional classes', () => {