(userlist, elements, responses, options: ObjectAnyType = {})
| 2 | import { NotAutenticatedError, ServerOfflineError } from '../../../src/_provider/Errors'; |
| 3 | |
| 4 | export function generalListTests(userlist, elements, responses, options: ObjectAnyType = {}) { |
| 5 | describe('Empty responses', async function() { |
| 6 | Object.keys(responses).forEach(async function(index) { |
| 7 | const value = responses[index].data; |
| 8 | it(index, async function() { |
| 9 | const temp = responses[index].data; |
| 10 | responses[index].data = ''; |
| 11 | try { |
| 12 | await new userlist(7, 'anime').getCompleteList(); |
| 13 | } catch (error) { |
| 14 | responses[index].data = temp; |
| 15 | let errorRes = 'UnexpectedResponseError'; |
| 16 | expect(error.name).to.equal(errorRes); |
| 17 | } |
| 18 | |
| 19 | responses[index].data = temp; |
| 20 | }); |
| 21 | }); |
| 22 | }); |
| 23 | |
| 24 | describe('No json responses', async function() { |
| 25 | Object.keys(responses).forEach(async function(index) { |
| 26 | const value = responses[index].data; |
| 27 | it(index, async function() { |
| 28 | const temp = responses[index].data; |
| 29 | responses[index].data = 'This is not valid json'; |
| 30 | try { |
| 31 | await new userlist(7, 'anime').getCompleteList(); |
| 32 | } catch (error) { |
| 33 | responses[index].data = temp; |
| 34 | let errorRes = 'UnexpectedResponseError'; |
| 35 | expect(error.name).to.equal(errorRes); |
| 36 | } |
| 37 | |
| 38 | responses[index].data = temp; |
| 39 | }); |
| 40 | }); |
| 41 | }); |
| 42 | |
| 43 | describe('errorHandling', async function() { |
| 44 | const list = new userlist(); |
| 45 | it('js', async function() { |
| 46 | expect(list.errorMessage(new Error('This is a error'), 'url')).to.equal('This is a error'); |
| 47 | }); |
| 48 | |
| 49 | it('Authentication', async function() { |
| 50 | expect(list.errorMessage(new NotAutenticatedError('No Authentication'), 'url')).to.equal('lang'); |
| 51 | }); |
| 52 | |
| 53 | it('Server offline', async function() { |
| 54 | expect(list.errorMessage(new ServerOfflineError('Offline'), 'url')).to.equal('Server Offline'); |
| 55 | }); |
| 56 | }); |
| 57 | } |
| 58 | |
| 59 | export function removeFn(list, test = true) { |
| 60 | for (const key in list) { |
no test coverage detected