-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UISACQCOMP-232: Move reusable helper function to support version hist…
…ory functionality (#833) * UISACQCOMP-232: Move reusable helper function to support version history functionality * test: fix failing test * refactor function name and folder * test: add test coverages
- Loading branch information
1 parent
e8132c3
commit 30b44ad
Showing
8 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import get from 'lodash/get'; | ||
|
||
export const getVersionMetadata = (version, entity) => ({ | ||
...get(entity, 'metadata', {}), | ||
updatedByUserId: version?.userId, | ||
updatedDate: version?.actionDate, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { getVersionMetadata } from './getVersionMetadata'; | ||
|
||
const version = { | ||
userId: 'userId', | ||
actionDate: '2024-11-21T05:14:30.510+00:00', | ||
eventDate: '2024-11-21T05:14:30.510+00:00', | ||
}; | ||
|
||
describe('getVersionMetadata', () => { | ||
it('should return metadata from entity and updatedByUserId and updatedDate from version', () => { | ||
const entity = { | ||
metadata: { | ||
metadataKey: 'metadataValue', | ||
createdDate: '2024-11-21T01:55:55.066+00:00', | ||
}, | ||
}; | ||
|
||
expect(getVersionMetadata(version, entity)).toEqual({ | ||
metadataKey: 'metadataValue', | ||
updatedByUserId: 'userId', | ||
updatedDate: version.actionDate, | ||
...entity.metadata, | ||
}); | ||
}); | ||
|
||
it('should return empty object if version is not provided', () => { | ||
expect(getVersionMetadata(null, {})).toEqual({}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { ACQUISITIONS_UNITS_API } from '../../constants'; | ||
import { fetchExportDataByIds } from '../fetchExportDataByIds'; | ||
|
||
export const fetchAcqUnitsByIds = (ky) => async (acquisitionUnitIds) => { | ||
return fetchExportDataByIds({ | ||
api: ACQUISITIONS_UNITS_API, | ||
ids: acquisitionUnitIds, | ||
ky, | ||
records: 'acquisitionsUnits', | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters