Skip to content

Commit

Permalink
Try to end up with useful errors
Browse files Browse the repository at this point in the history
  • Loading branch information
SubJunk committed Jan 4, 2020
1 parent 2d968fa commit 354f73b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions test/e2e/media.spec.ts
Expand Up @@ -35,7 +35,13 @@ describe('Media Metadata endpoints', () => {

it('should return a valid response for a new osdbhash, then store it', async() => {
// using example file from https://trac.opensubtitles.org/projects/opensubtitles/wiki/HashSourceCodes
const res = await axios(`${appUrl}/api/media/8e245d9679d31e12/12909756`);
let res;
try {
res = await axios(`${appUrl}/api/media/8e245d9679d31e12/12909756`);
} catch (err) {
throw new Error(err.response);
}

expect(res.status).toBe(200);
expect(res.data).toHaveProperty('_id');
expect(res.data).toHaveProperty('year', '2007');
Expand Down Expand Up @@ -65,7 +71,12 @@ describe('Media Metadata endpoints', () => {

it('should create a failed lookup document when Open Subtitles cannot find metadata', async() => {
await FailedLookupsModel.deleteMany({});
const response = await axios(`${appUrl}/api/media/f4245d9379d31e30/1234`);
let response;
try {
response = await axios(`${appUrl}/api/media/f4245d9379d31e30/1234`);
} catch (err) {
throw new Error(err.response);
}
expect(response.data.message).toBe('Metadata not found on OpenSubtitles');
const doc = await FailedLookupsModel.findOne({ osdbHash: 'f4245d9379d31e30' });
expect(doc).toHaveProperty('_id');
Expand Down

0 comments on commit 354f73b

Please sign in to comment.