Skip to content

Commit 329a1b7

Browse files
committed
Change error test endpoint.
- https://httpstat.us/404 endpoint does JSON output and CORS (needed for karma tests).
1 parent 3e0cd24 commit 329a1b7

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

tests/10-client-api.spec.common.cjs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ describe('http-client API', () => {
200200
let response;
201201
try {
202202
response = await httpClient.get(
203-
'https://dog.ceo/api/breeds/image/DOESNOTEXIST');
203+
// FIXME: update to use local test endpoint to avoid output changes
204+
'https://httpstat.us/404');
204205
} catch(e) {
205206
err = e;
206207
}
@@ -211,22 +212,20 @@ describe('http-client API', () => {
211212
should.exist(err.response.status);
212213
should.exist(err.status);
213214
err.status.should.equal(404);
214-
// FIXME: update to use local test endpoint, dog.ceo changed its output.
215-
should.not.exist(err.data);
216-
//should.exist(err.data);
217-
//err.data.should.be.an('object');
218-
//// these are API specific from the JSON body of the response
219-
//err.data.should.have.keys(['status', 'message', 'code']);
220-
//err.data.status.should.equal('error');
221-
//err.data.message.should.contain('No route found');
222-
//err.data.code.should.equal(404);
215+
should.exist(err.data);
216+
err.data.should.be.an('object');
217+
// these are API specific from the JSON body of the response
218+
err.data.should.have.keys(['code', 'description']);
219+
err.data.code.should.equal(404);
220+
err.data.description.should.equal('Not Found');
223221
});
224222
it('handles a direct get not found error with JSON data', async () => {
225223
let err;
226224
let response;
227225
try {
228226
response = await httpClient(
229-
'https://dog.ceo/api/breeds/image/DOESNOTEXIST');
227+
// FIXME: update to use local test endpoint to avoid output changes
228+
'https://httpstat.us/404');
230229
} catch(e) {
231230
err = e;
232231
}
@@ -237,15 +236,12 @@ describe('http-client API', () => {
237236
should.exist(err.response.status);
238237
should.exist(err.status);
239238
err.status.should.equal(404);
240-
// FIXME: update to use local test endpoint, dog.ceo changed its output.
241-
should.not.exist(err.data);
242-
//should.exist(err.data);
243-
//err.data.should.be.an('object');
244-
//// these are API specific from the JSON body of the response
245-
//err.data.should.have.keys(['status', 'message', 'code']);
246-
//err.data.status.should.equal('error');
247-
//err.data.message.should.contain('No route found');
248-
//err.data.code.should.equal(404);
239+
should.exist(err.data);
240+
err.data.should.be.an('object');
241+
// these are API specific from the JSON body of the response
242+
err.data.should.have.keys(['code', 'description']);
243+
err.data.code.should.equal(404);
244+
err.data.description.should.equal('Not Found');
249245
});
250246
if(isNode) {
251247
describe('Nodejs execution context', () => {

0 commit comments

Comments
 (0)