-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from NYPL-discovery/noref-improvements
Improvements related to schema posting, patching
- Loading branch information
Showing
7 changed files
with
143 additions
and
14 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
language: node_js | ||
install: npm install | ||
script: npm test |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,24 @@ | ||
{ | ||
"data": { | ||
"id": 1234, | ||
"jobId": "1106896193cb7216d96", | ||
"createdDate": "2021-11-16T10:17:06-05:00", | ||
"updatedDate": "2021-11-16T10:17:12-05:00", | ||
"success": false, | ||
"processed": true, | ||
"patron": "987654321", | ||
"nyplSource": "sierra-nypl", | ||
"requestType": "hold", | ||
"recordType": "i", | ||
"record": "15371503", | ||
"pickupLocation": "", | ||
"deliveryLocation": "NH", | ||
"neededBy": "2022-11-16T00:00:00-05:00", | ||
"numberOfCopies": 1, | ||
"docDeliveryData": null, | ||
"error": null | ||
}, | ||
"count": 1, | ||
"statusCode": 200, | ||
"debugInfo": [] | ||
} |
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,54 @@ | ||
let client = null | ||
|
||
describe('Client PATCH method', function () { | ||
beforeEach(() => { | ||
client = require('./make-test-client')() | ||
}) | ||
|
||
afterEach(() => { | ||
client = null | ||
}) | ||
|
||
// This is a common patch that the | ||
// [HoldRequestResultConsumer makes](https://github.com/NYPL/hold-request-result-consumer/blob/e7bd5b04afe25cf65ed2a5ce2de0576973e592cb/src/OAuthClient/HoldRequestClient.php#L123) | ||
// makes when it detects a hold-request has been fulfilled | ||
var holdRequestPatch = { | ||
success: true, | ||
processed: true | ||
} | ||
|
||
describe('when config.json=true (default)', function () { | ||
it('should accept a new schema object via PATCH and return an object', function () { | ||
return client.patch('hold-requests/1234', holdRequestPatch) | ||
.then((resp) => { | ||
expect(resp).to.be.a('object') | ||
}) | ||
}) | ||
|
||
it('should fail if supplied body is plaintext', function () { | ||
let call = client.patch('hold-requests/1234', JSON.stringify(holdRequestPatch)) | ||
return expect(call).to.be.rejected | ||
}) | ||
|
||
// A null/empty body should be accepted as valid if options.json===true | ||
it('should succeed if supplied body is empty', function () { | ||
let call = client.patch('hold-requests/1234') | ||
return expect(call).to.be.fulfilled | ||
}) | ||
}) | ||
|
||
describe('when config.json=false', function () { | ||
it('should accept a plaintext body and return plain text', function () { | ||
let call = client.patch('hold-requests/1234', JSON.stringify(holdRequestPatch), { json: false }) | ||
return Promise.all([ | ||
expect(call).to.be.fulfilled, | ||
expect(call).to.eventually.be.a('string') | ||
]) | ||
}) | ||
|
||
it('should fail if supplied body is not plaintext', function () { | ||
let call = client.patch('hold-requests/1234', holdRequestPatch, { json: false }) | ||
return expect(call).to.be.rejected | ||
}) | ||
}) | ||
}) |