|
| 1 | +const { rejects } = require('node:assert/strict') |
1 | 2 | const { fetchSpy } = require('./helper') |
2 | 3 |
|
3 | 4 | let client = null |
@@ -47,20 +48,23 @@ describe('Client POST method', function () { |
47 | 48 |
|
48 | 49 | it('should fail if supplied body is plaintext', () => { |
49 | 50 | 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 | + }) |
51 | 55 | }) |
52 | 56 |
|
53 | 57 | // 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' } }) |
57 | 61 | }) |
58 | 62 | }) |
59 | 63 |
|
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') |
64 | 68 | }) |
65 | 69 | }) |
66 | 70 | }) |
0 commit comments