fixed id bug

This commit is contained in:
Peter Holmberg 2018-12-11 14:45:18 +01:00
parent ddf080dab6
commit db87c5126b
2 changed files with 7 additions and 1 deletions

View File

@ -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);
});
});

View File

@ -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,
};
}