Skip to content

Commit

Permalink
feat: remove form-control-file class
Browse files Browse the repository at this point in the history
  • Loading branch information
darreneng authored and phwebi committed Oct 27, 2021
1 parent 1e6204b commit f601576
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
3 changes: 0 additions & 3 deletions src/Input.js
Expand Up @@ -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';
Expand All @@ -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) {
Expand Down
19 changes: 7 additions & 12 deletions src/__tests__/Input.spec.js
Expand Up @@ -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(<Input />);

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(<Input type="file" />);

expect(wrapper.hasClass('form-control')).toBe(false);
expect(wrapper.hasClass('form-control-plaintext')).toBe(false);
expect(wrapper.hasClass('form-check-input')).toBe(false);
});
Expand All @@ -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(<Input type="file" plaintext />);

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(<Input type="radio" />);

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(<Input type="checkbox" />);

expect(wrapper.hasClass('form-control-file')).toBe(false);
expect(wrapper.hasClass('form-control-plaintext')).toBe(false);
expect(wrapper.hasClass('form-control')).toBe(false);
});
Expand Down Expand Up @@ -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(<Input type="file" />);

expect(wrapper.hasClass('form-control-file')).toBe(true);
expect(wrapper.hasClass('form-control')).toBe(true);
});

it('should render additional classes', () => {
Expand Down

0 comments on commit f601576

Please sign in to comment.