mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 09:30:31 +03:00
Created DateInput component test
This commit is contained in:
parent
faa828c58a
commit
f23245a39c
2 changed files with 45 additions and 5 deletions
|
@ -24,11 +24,13 @@ export default class DateInput extends React.Component {
|
||||||
readOnly
|
readOnly
|
||||||
ref={this.inputRef}
|
ref={this.inputRef}
|
||||||
/>
|
/>
|
||||||
{showCalendarIcon && <FontAwesomeIcon
|
{showCalendarIcon && (
|
||||||
|
<FontAwesomeIcon
|
||||||
icon={calendarIcon}
|
icon={calendarIcon}
|
||||||
className="date-input-container__icon"
|
className="date-input-container__icon"
|
||||||
onClick={() => this.inputRef.current.input.focus()}
|
onClick={() => this.inputRef.current.input.focus()}
|
||||||
/>}
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
38
test/common/DateInput.test.js
Normal file
38
test/common/DateInput.test.js
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { shallow } from 'enzyme';
|
||||||
|
import DateInput from '../../src/common/DateInput';
|
||||||
|
import FontAwesomeIcon from '@fortawesome/react-fontawesome';
|
||||||
|
|
||||||
|
describe('<DateInput />', () => {
|
||||||
|
let wrapped;
|
||||||
|
|
||||||
|
const createComponent = (props = {}) => {
|
||||||
|
wrapped = shallow(<DateInput {...props} />);
|
||||||
|
return wrapped;
|
||||||
|
};
|
||||||
|
afterEach(() => {
|
||||||
|
if (wrapped !== undefined) {
|
||||||
|
wrapped.unmount();
|
||||||
|
wrapped = undefined;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('wrapps a DatePicker', () => {
|
||||||
|
wrapped = createComponent();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows calendar icon when input is not clearable', () => {
|
||||||
|
wrapped = createComponent({ isClearable: false });
|
||||||
|
expect(wrapped.find(FontAwesomeIcon)).toHaveLength(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows calendar icon when input is clearable but selected value is nil', () => {
|
||||||
|
wrapped = createComponent({ isClearable: true, selected: null });
|
||||||
|
expect(wrapped.find(FontAwesomeIcon)).toHaveLength(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not show calendar icon when input is clearable', () => {
|
||||||
|
wrapped = createComponent({ isClearable: true, selected: '' });
|
||||||
|
expect(wrapped.find(FontAwesomeIcon)).toHaveLength(0);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in a new issue