diff --git a/specifyweb/frontend/js_src/lib/components/WbPlanView/__tests__/mappingReducer.test.ts b/specifyweb/frontend/js_src/lib/components/WbPlanView/__tests__/mappingReducer.test.ts new file mode 100644 index 00000000000..c8d563e5cfb --- /dev/null +++ b/specifyweb/frontend/js_src/lib/components/WbPlanView/__tests__/mappingReducer.test.ts @@ -0,0 +1,36 @@ +import { requireContext } from '../../../tests/helpers'; +import { defaultColumnOptions } from '../linesGetter'; +import { getDefaultMappingState } from '../Mapper'; +import { emptyMapping } from '../mappingHelpers'; +import { reducer } from '../mappingReducer'; + +requireContext(); + +// [WorkBench] Select a field mapping in the Data Mapper +test('selects a field mapping', () => { + const state = getDefaultMappingState({ + changesMade: false, + lines: [ + { + headerName: 'Catalog Number', + mappingPath: [emptyMapping], + columnOptions: defaultColumnOptions, + }, + ], + mustMatchPreferences: {}, + }); + + const updatedState = reducer(state, { + type: 'ChangeSelectElementValueAction', + line: 0, + index: 0, + newValue: 'catalogNumber', + isRelationship: false, + parentTableName: 'CollectionObject', + newTableName: undefined, + currentTableName: undefined, + }); + + expect(updatedState.lines[0].mappingPath).toEqual(['catalogNumber']); + expect(updatedState.changesMade).toBe(true); +});