Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
client error handling tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RusAlex committed Oct 28, 2016
1 parent 4eee7f8 commit 79f7201
Showing 1 changed file with 46 additions and 6 deletions.
52 changes: 46 additions & 6 deletions test/integration/api/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import fs from 'fs';
import { serialize } from 'cookie';
import AWS from 'mock-aws';
import { v4 } from 'uuid';

import expect from '../../../test-helpers/expect';
import { login } from '../../../test-helpers/api';
Expand Down Expand Up @@ -78,16 +79,55 @@ describe('Client test', () => {
});

it('#deleteComment works', async () => {
let result = await client.deleteComment('nonexistingpost', 'nonexistingid');

expect(result.error, 'to be', 'You are not authorized');
return expect(client.deleteComment('nonexistingpost', 'nonexistingid'), 'to be rejected with', 'You are not authorized');
});

it('#search works', async () => {
const result = await client.search('test');
return expect(client.search('test'), 'to be rejected with', 'Search failed');
});

it('#userInfo works', async () => {
return expect(client.userInfo('nonexisting'), 'to be rejected with', 'Not Found');
});

it('#getSchool correctly handle non existing school call', async () => {
return expect(client.getSchool('nonexisting'), 'to be rejected with', 'Not Found');
});

it('#relatedPosts correctly handle non existing post id ', async () => {
return expect(client.relatedPosts(v4()), 'to be rejected with', 'Internal Server Error');
});

it('#userTags correctly handle non authenticated request', async () => {
return expect(client.userTags(), 'to be rejected with', 'You are not authorized');
});

it('#userLikedPosts correctly handle errors', async () => {
return expect(client.userLikedPosts(), 'to be rejected with', 'You are not authorized');
});

it('#userFavouredPosts correctly handle errors', async () => {
return expect(client.userFavouredPosts(), 'to be rejected with', 'You are not authorized');
});

it('#geotagPosts correctly handle non existing geotag', async () => {
return expect(client.geotagPosts('nonexistinggeotag'), 'to be rejected with', 'Not Found');
});

it('#city correctly handle non existing entity', async () => {
return expect(client.city('nonexistingcity'), 'to be rejected with', 'Not Found');
});

it('#country correctly handle non existing entity', async () => {
return expect(client.country('nonexistingcountry'), 'to be rejected with', 'Not Found');
});

it('#like correctly handle non authenticated request', async () => {
return expect(client.like(), 'to be rejected with', 'You are not authorized');
});

expect(result, 'to be an', 'object');
expect(result, 'to have key', 'error');
it('#unlike correctly handle non authenticated request', async () => {
return expect(client.unlike('dummyid'), 'to be rejected with', 'You are not authorized');
});
});

Expand Down

0 comments on commit 79f7201

Please sign in to comment.