Skip to content

Commit 81bbddc

Browse files
committed
Remove chai-as-promised
1 parent c48fdf2 commit 81bbddc

6 files changed

Lines changed: 23 additions & 39 deletions

File tree

bin/nypl-data-api.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const printResponse = (resp) => {
2727
// If JSON, format as json, otherwise print as-is:
2828
try { Object.keys(resp).length >= 1 && (formattedResponse = JSON.stringify(resp, null, 2)) } catch (e) { }
2929
}
30-
console.log('Response: \n', formattedResponse)
30+
console.log('Response:')
31+
console.log(formattedResponse)
3132

3233
// Detect the distinct API Gateway bad-request-path error:
3334
if (resp?.message?.includes(' not a valid key=value pair ')) {

package-lock.json

Lines changed: 0 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
},
2222
"devDependencies": {
2323
"chai": "^4.1.2",
24-
"chai-as-promised": "^7.1.1",
2524
"jsdoc-to-markdown": "^8.0.1",
2625
"mocha": "^10.4.0",
2726
"prompts": "^2.4.2",

test/helper.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
const oauth = require('oauth')
22
const sinon = require('sinon')
33
const chai = require('chai')
4-
const chaiAsPromised = require('chai-as-promised')
54
const { fixtureForRequest } = require('./fixtures')
65

7-
chai.use(chaiAsPromised)
86
global.expect = chai.expect
97

108
let _fetchSpy

test/patch-test.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { rejects } = require('node:assert/strict')
12
const { fetchSpy } = require('./helper')
23

34
let client = null
@@ -43,20 +44,23 @@ describe('Client PATCH method', function () {
4344

4445
it('should fail if supplied body is plaintext', async () => {
4546
const call = client.patch('hold-requests/1234', JSON.stringify(holdRequestPatch))
46-
await expect(call).to.be.rejectedWith('Attempted to PATCH with options.json==true, but body is a string')
47+
return rejects(call, {
48+
name: 'RequestError',
49+
message: 'Attempted to PATCH with options.json==true, but body is a string'
50+
})
4751
})
4852

4953
// A null/empty body should be accepted as valid if options.json===true
5054
it('should succeed if supplied body is empty', async () => {
51-
const call = client.patch('hold-requests/1234')
52-
await expect(call).to.be.eventually.be.a('object')
55+
const call = await client.patch('hold-requests/1234')
56+
expect(call).to.be.a('object')
5357
})
5458
})
5559

5660
describe('when config.json=false', () => {
5761
it('should accept a plaintext body and return plain text', async () => {
58-
const call = client.patch('hold-requests/1234', JSON.stringify(holdRequestPatch), { json: false })
59-
await expect(call).to.eventually.be.a('string')
62+
const res = await client.patch('hold-requests/1234', JSON.stringify(holdRequestPatch), { json: false })
63+
await expect(res).be.a('string')
6064
})
6165
})
6266
})

test/post-test.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { rejects } = require('node:assert/strict')
12
const { fetchSpy } = require('./helper')
23

34
let client = null
@@ -47,20 +48,23 @@ describe('Client POST method', function () {
4748

4849
it('should fail if supplied body is plaintext', () => {
4950
const call = client.post(`schemas/${testSchema.name}`, JSON.stringify(testSchema))
50-
return expect(call).to.be.rejectedWith('Attempted to POST with options.json==true, but body is a string')
51+
return rejects(call, {
52+
name: 'RequestError',
53+
message: 'Attempted to POST with options.json==true, but body is a string'
54+
})
5155
})
5256

5357
// A null/empty body should be accepted as valid if options.json===true
54-
it('should succeed if supplied body is empty', () => {
55-
const call = client.post(`schemas/${testSchema.name}`)
56-
return expect(call).to.be.fulfilled
58+
it('should succeed if supplied body is empty', async () => {
59+
const resp = await client.post(`schemas/${testSchema.name}`)
60+
return expect(resp).to.deep.eq({ data: { stream: 'TestSchema' } })
5761
})
5862
})
5963

60-
describe('when config.json=false', () => {
61-
it('should accept a plaintext body and return plain text', () => {
62-
const call = client.post(`schemas/${testSchema.name}`, JSON.stringify(testSchema), { json: false })
63-
return expect(call).to.eventually.be.a('string')
64+
describe('when config.json=false', async () => {
65+
it('should accept a plaintext body and return plain text', async () => {
66+
const call = await client.post(`schemas/${testSchema.name}`, JSON.stringify(testSchema), { json: false })
67+
expect(call).to.be.a('string')
6468
})
6569
})
6670
})

0 commit comments

Comments
 (0)