Skip to content

Commit 47a083b

Browse files
committed
Add test for clearing value
1 parent ea054e8 commit 47a083b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/__tests__/DateTimeInput.jsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,30 @@ describe('DateTimeInput', () => {
102102
expect(customInputs.at(5).getDOMNode().value).toBe('0');
103103
});
104104

105+
it('clears the value correctly', () => {
106+
const date = new Date(2017, 8, 30, 22, 17, 0);
107+
108+
const component = mount(
109+
<DateTimeInput
110+
maxDetail="second"
111+
value={date}
112+
/>
113+
);
114+
115+
component.setProps({ value: null });
116+
117+
const nativeInput = component.find('input[type="datetime-local"]');
118+
const customInputs = component.find('input[type="number"]');
119+
120+
expect(nativeInput.getDOMNode().value).toBe('');
121+
expect(customInputs.at(0).getDOMNode().value).toBe('');
122+
expect(customInputs.at(1).getDOMNode().value).toBe('');
123+
expect(customInputs.at(2).getDOMNode().value).toBe('');
124+
expect(customInputs.at(3).getDOMNode().value).toBe('');
125+
expect(customInputs.at(4).getDOMNode().value).toBe('');
126+
expect(customInputs.at(5).getDOMNode().value).toBe('');
127+
});
128+
105129
it('renders custom inputs in a proper order (en-US)', () => {
106130
const component = mount(
107131
<DateTimeInput

0 commit comments

Comments
 (0)