-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Failed-record errors from "message" instead of "label" (#71)
When a error structure has a `message` as well as a `label`, use the former rather than the latter. We still fall back to the label when there is no message. Add tests for both cases. These are in fact the first tests in the module, so now for the first time it's possible to run `yarn test`. A little bit of infrastructure was added to support the use of Jest. Fixes UIHAADM-125.
- Loading branch information
1 parent
3a1fdde
commit 0577144
Showing
6 changed files
with
42 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
junit.xml | ||
node_modules | ||
yarn.lock |
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 @@ | ||
module.exports = require('@folio/jest-config-stripes'); |
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,29 @@ | ||
import { errors2string } from './summarizeErrors'; | ||
|
||
const errorFromMessage = `[ | ||
{ | ||
"error": { | ||
"label": "Error encountered during upsert of Inventory record set", | ||
"message": "ERROR: Cannot update record c352fe11-51e2-4e8b-87d6-578d6dedec8b because it has been changed (optimistic locking): Stored _version is 4, _version of request is 1 (23F09)" | ||
} | ||
} | ||
]`; | ||
|
||
const errorFromLabel = `[ | ||
{ | ||
"error": { | ||
"label": "Error encountered during upsert of Inventory record set" | ||
} | ||
} | ||
]`; | ||
|
||
|
||
test('summarizes simple error from message', () => { | ||
const errorsData = JSON.parse(errorFromMessage); | ||
expect(errors2string(errorsData)).toBe('ERROR: Cannot update record c352fe11-51e2-4e8b-87d6-578d6dedec8b because it has been changed (optimistic locking): Stored _version is 4, _version of request is 1 (23F09)'); | ||
}); | ||
|
||
test('summarizes simple error from label', () => { | ||
const errorsData = JSON.parse(errorFromLabel); | ||
expect(errors2string(errorsData)).toBe('Error encountered during upsert of Inventory record set'); | ||
}); |