@@ -51,4 +51,10 @@ describe('Next id to add', () => {
expect(instance.state.nextIdToAdd).toEqual(4);
});
+
+ it('should default to 1', () => {
+ const instance = setup({ options: { ...defaultProps.options } });
+ expect(instance.state.nextIdToAdd).toEqual(1);
+ });
@@ -16,7 +16,7 @@ export default class ValueMappings extends PureComponent<OptionModuleProps, Stat
this.state = {
mappings: mappings || [],
- nextIdToAdd: mappings ? this.getMaxIdFromMappings(mappings) : 1,
+ nextIdToAdd: mappings.length > 0 ? this.getMaxIdFromMappings(mappings) : 1,
};
}