All files / src/app/core/utils/dev api-service-utils.ts

18.18% Statements 4/22
100% Branches 0/0
50% Functions 1/2
21.05% Lines 4/19

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 4083x           83x                                                     83x 423x          
import { capture } from 'ts-mockito';
 
import { HttpError } from 'ish-core/models/http-error/http-error.model';
import { ApiService } from 'ish-core/services/api/api.service';
 
/* eslint-disable no-console */
export function logApiCalls(apiServiceMock: ApiService) {
  for (let i = 0; i < 100; i++) {
    try {
      const args = capture(apiServiceMock.get).byCallIndex(i);
      console.log('GET', args);
    } catch (err) {
      break;
    }
  }
  for (let i = 0; i < 100; i++) {
    try {
      const args = capture(apiServiceMock.post).byCallIndex(i);
      console.log('POST', args);
    } catch (err) {
      break;
    }
  }
  for (let i = 0; i < 100; i++) {
    try {
      const args = capture(apiServiceMock.put).byCallIndex(i);
      console.log('PUT', args);
    } catch (err) {
      break;
    }
  }
}
 
export function makeHttpError(fields: Partial<HttpError>): HttpError {
  return {
    name: 'HttpErrorResponse',
    ...fields,
  };
}