-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MMT-3922: Created new file for testing purposes
- Loading branch information
1 parent
6e38c5f
commit b1e6ef9
Showing
4 changed files
with
30 additions
and
52 deletions.
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
15 changes: 15 additions & 0 deletions
15
static/src/js/utils/__tests__/checkForCMRFetchDraftLag.test.js
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,15 @@ | ||
import checkForCMRFetchDraftLag from '../checkForCMRFetchDraftLag' | ||
|
||
describe('checkForCMRFetchDraftLag', () => { | ||
describe('when the fetched revision Id and expected revision Id are undefined', () => { | ||
test('returns undefined', () => { | ||
expect(checkForCMRFetchDraftLag(`${undefined}`, `${undefined}`)).toEqual(undefined) | ||
}) | ||
}) | ||
|
||
describe('when the fetched revision Id does not match expected revision Id', () => { | ||
test('throws error', () => { | ||
expect(() => checkForCMRFetchDraftLag('1', '2')).toThrow('Delay in CMR has detected. Refresh the page in order to see latest revision') | ||
}) | ||
}) | ||
}) |
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,13 @@ | ||
/** | ||
* Compares the revision Ids to ensure the draft retched is the most current | ||
* @param {String} fetchedRevisionId The revision Id that comes back from CMR | ||
* @param {String} expectedRevisionId The revision Id that was set on ingest (expected revision) | ||
*/ | ||
|
||
const checkForCMRFetchDraftLag = (fetchedRevisionId, expectedRevisionId) => { | ||
if ((fetchedRevisionId && expectedRevisionId) && (fetchedRevisionId !== expectedRevisionId)) { | ||
throw new Error('Delay in CMR has detected. Refresh the page in order to see latest revision') | ||
} | ||
} | ||
|
||
export default checkForCMRFetchDraftLag |