mirror of
https://github.com/mjrode/WhatToWatch.git
synced 2026-01-06 05:29:34 -06:00
WIP: Building out error handling.
This commit is contained in:
@@ -22,6 +22,17 @@ describe('Users', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle request error', (done) => {
|
||||
chai
|
||||
.request(app)
|
||||
.get('/plex/users')
|
||||
.end((err, res) => {
|
||||
res.should.have.status(500);
|
||||
res.body.message.should.equal('An unknown error occurred.');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -102,6 +113,7 @@ describe('Library Data', () => {
|
||||
.get('/api/users?X-Plex-Token')
|
||||
.end((err, res) => {
|
||||
res.should.have.status(404);
|
||||
res.text.should.equal('Page Not Found');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,6 +21,12 @@ describe('plexApi', () => {
|
||||
url.should.equal('https://plex.tv/api/users?X-Plex-Token=testPlexApiToken');
|
||||
});
|
||||
|
||||
it('handles error when building url', () => {
|
||||
const urlParams = 'invalid params';
|
||||
const url = helpers.buildUrl(urlParams);
|
||||
url.message.should.equal('Invalid urlParams: invalid params');
|
||||
});
|
||||
|
||||
it('returns users', async () => {
|
||||
nocks.plexUsers();
|
||||
|
||||
@@ -44,4 +50,17 @@ describe('plexApi', () => {
|
||||
plexResponses.getLibraryDataBySectionRaw.MediaContainer.Metadata,
|
||||
);
|
||||
});
|
||||
|
||||
// it.only('handles error if passed incorrect parameters', async (done) => {
|
||||
// try {
|
||||
// await plexApi.getLibraryDataBySection('incorrect param');
|
||||
// } catch (error) {
|
||||
// console.log('CAUGHTEM', error);
|
||||
// error.code.should.equal(401);
|
||||
// error.message.should.equal('Unauthorized');
|
||||
// error.code.should.equal(
|
||||
// 'https://plex.mjrflix.com/library/sections/undefined/all?X-Plex-Token=testPlexApiToken',
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user