await new Promise(setImmediate);
expect(wrapper.find('ValidationInput').prop('isInvalid')).toBe(true);
});
+
+it('should handle Change', async () => {
+ const onChange = jest.fn();
+ const wrapper = shallow(<ProjectKeyInput onChange={onChange} value="" />);
+ await waitAndUpdate(wrapper);
+
+ wrapper.find('input').simulate('change', { currentTarget: { value: 'key' } });
+
+ expect(wrapper.state('touched')).toBe(true);
+ expect(onChange).toBeCalledWith('key');
+});
+
+it('should ignore promise return if value has been changed in the meantime', async () => {
+ const onChange = (value: string) => wrapper.setProps({ value });
+ const wrapper = shallow(<ProjectKeyInput onChange={onChange} value="" />);
+ await waitAndUpdate(wrapper);
+
+ wrapper.find('input').simulate('change', { currentTarget: { value: 'exists' } });
+ wrapper.find('input').simulate('change', { currentTarget: { value: 'exists%' } });
+
+ jest.runAllTimers();
+ await new Promise(setImmediate);
+
+ expect(wrapper.state('touched')).toBe(true);
+ expect(wrapper.state('error')).toBe('onboarding.create_project.project_key.error');
+});
});
it('bulk applies template to selected results', async () => {
- const wrapper = shallow(render({ selection: ['proj1', 'proj2'] }));
+ const wrapper = shallow(render({ qualifier: 'VW', selection: ['proj1', 'proj2'] }));
(wrapper.instance() as BulkApplyTemplateModal).mounted = true;
expect(wrapper).toMatchSnapshot();
expect(bulkApplyTemplate).toBeCalledWith({
organization: 'org',
projects: 'proj1,proj2',
+ qualifiers: 'VW',
templateId: 'foo'
});
renderIssueMeasures = () => {
const { branchLike, issues, sourceViewerFile } = this.props;
- if (issues && issues.length > 0) {
- return (
+ return (
+ issues &&
+ issues.length > 0 && (
<>
<div className="source-viewer-header-measure-separator" />
);
})}
</>
- );
- }
+ )
+ );
};
render() {