-
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
- Loading branch information
1 parent
e8132c3
commit 99aaaa4
Showing
7 changed files
with
60 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,38 @@ | ||
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: 'actionDate', | ||
}); | ||
}); | ||
|
||
it('should return empty object if entity is not provided', () => { | ||
expect(getVersionMetadata(version)).toEqual({}); | ||
}); | ||
|
||
it('should return empty object if version is not provided', () => { | ||
const entity = { | ||
metadata: { | ||
metadataKey: 'metadataValue', | ||
}, | ||
}; | ||
|
||
expect(getVersionMetadata(null, entity)).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
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 getAcqUnitsByIds = (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