{"size": 7000, "ext": "js", "max_stars_repo_path": "frontend/tests/containers/offline/connection/qlf-api.test.js", "max_stars_repo_name": "desihub/qlf", "max_stars_repo_stars_event_min_datetime": "2017-09-08T00:24:20.000Z", "max_stars_repo_stars_event_max_datetime": "2019-02-03T07:31:03.000Z", "max_issues_repo_path": "frontend/tests/containers/offline/connection/qlf-api.test.js", "max_issues_repo_name": "desihub/qlf", "max_issues_repo_issues_event_min_datetime": "2017-06-15T21:39:09.000Z", "max_issues_repo_issues_event_max_datetime": "2019-07-13T19:41:27.000Z", "max_forks_repo_path": "frontend/tests/containers/offline/connection/qlf-api.test.js", "max_forks_repo_name": "desihub/qlf", "max_forks_repo_forks_event_min_datetime": "2017-09-10T02:25:03.000Z", "max_forks_repo_forks_event_max_datetime": "2019-02-06T20:55:59.000Z"}
{"max_stars_count": 8, "max_issues_count": 77, "max_forks_count": 5, "avg_line_length": 25.0, "max_line_length": 150, "alphanum_fraction": 0.5122857143}
import QlfApi from '../../../../src/containers/offline/connection/qlf-api';

describe('QlfApi', () => {
  beforeEach(() => {
    fetch.mockReset();
  });

  it('calls getQA', () => {
    QlfApi.getQA(1);
    expect(fetch).toBeCalledWith(
      'http://localhost:8001/dashboard/api/processing_history/1/?format=json',
      {
        headers: {
          _headers: {
            accept: ['application/json'],
            'content-type': ['application/json'],
          },
        },
        method: 'GET',
      }
    );
  });

  it('calls getLastProcess', () => {
    QlfApi.getLastProcess();
    expect(fetch).toBeCalledWith(
      'http://localhost:8001/dashboard/api/last_process/?format=json',
      {
        headers: {
          _headers: {
            accept: ['application/json'],
            'content-type': ['application/json'],
          },
        },
        method: 'GET',
      }
    );
  });

  it('calls reprocessExposure', () => {
    QlfApi.reprocessExposure(3);
    expect(fetch).toBeCalledWith(
      'http://localhost:8001/dashboard/api/add_exposure/?format=json&exposure_id=3',
      {
        headers: {
          _headers: {
            accept: ['application/json'],
            'content-type': ['application/json'],
          },
        },
        method: 'GET',
      }
    );
  });

  it('calls getProcessingHistoryById', () => {
    QlfApi.getProcessingHistoryById(3);
    expect(fetch).toBeCalledWith(
      'http://localhost:8001/dashboard/api/processing_history/3/?format=json',
      {
        headers: {
          _headers: {
            accept: ['application/json'],
            'content-type': ['application/json'],
          },
        },
        method: 'GET',
      }
    );
  });

  it('calls getCurrentConfiguration', () => {
    QlfApi.getCurrentConfiguration();
    expect(fetch).toBeCalledWith(
      'http://localhost:8001/dashboard/api/current_configuration/?format=json',
      {
        headers: {
          _headers: {
            accept: ['application/json'],
            'content-type': ['application/json'],
          },
        },
        method: 'GET',
      }
    );
  });

  it('calls getDefaultConfiguration', () => {
    QlfApi.getDefaultConfiguration();
    expect(fetch).toBeCalledWith(
      'http://localhost:8001/dashboard/api/default_configuration/?format=json',
      {
        headers: {
          _headers: {
            accept: ['application/json'],
            'content-type': ['application/json'],
          },
        },
        method: 'GET',
      }
    );
  });

  it('calls getQlConfig', () => {
    QlfApi.getQlConfig('flat');
    expect(fetch).toBeCalledWith(
      'http://localhost:8001/dashboard/api/qlconfig/?format=json&type=flat',
      {
        headers: {
          _headers: {
            accept: ['application/json'],
            'content-type': ['application/json'],
          },
        },
        method: 'GET',
      }
    );
  });

  it('calls getExposuresDateRange', () => {
    QlfApi.getExposuresDateRange();
    expect(fetch).toBeCalledWith(
      'http://localhost:8001/dashboard/api/exposures_date_range/',
      {
        headers: {
          _headers: {
            accept: ['application/json'],
            'content-type': ['application/json'],
          },
        },
        method: 'GET',
      }
    );
  });

  it('calls getFlavors', () => {
    QlfApi.getFlavors();
    expect(fetch).toBeCalledWith(
      'http://localhost:8001/dashboard/api/distinct_flavors/',
      {
        headers: {
          _headers: {
            accept: ['application/json'],
            'content-type': ['application/json'],
          },
        },
        method: 'GET',
      }
    );
  });

  it('calls getProcessingHistory', () => {
    QlfApi.getProcessingHistory(
      '2019-01-01',
      '2019-01-01',
      '-pk',
      '2',
      '10',
      null
    );
    expect(fetch).toBeCalledWith(
      'http://localhost:8001/dashboard/api/processing_history/?format=json&limit=10&offset=2&ordering=-pk&datemin=2019-01-01&datemax=2019-01-01&null',
      {
        headers: {
          _headers: {
            accept: ['application/json'],
            'content-type': ['application/json'],
          },
        },
        method: 'GET',
      }
    );
  });

  it('calls getObservingHistory', () => {
    QlfApi.getObservingHistory(
      '2019-01-01',
      '2019-01-01',
      '-pk',
      '2',
      '10',
      null
    );
    expect(fetch).toBeCalledWith(
      'http://localhost:8001/dashboard/api/observing_history/?format=json&limit=10&offset=2&ordering=-pk&datemin=2019-01-01&datemax=2019-01-01&null',
      {
        headers: {
          _headers: {
            accept: ['application/json'],
            'content-type': ['application/json'],
          },
        },
        method: 'GET',
      }
    );
  });

  it('calls addProcessComment', () => {
    QlfApi.addProcessComment('testing configuration', 1);
    expect(fetch).toBeCalledWith(
      'http://localhost:8001/dashboard/api/process_comment/',
      {
        body: '{"text":"testing configuration","process":1,"user":1}',
        headers: {
          _headers: {
            accept: ['application/json'],
            'content-type': ['application/json'],
          },
        },
        method: 'POST',
      }
    );
  });

  it('calls deleteProcessComment', () => {
    QlfApi.deleteProcessComment(3);
    expect(fetch).toBeCalledWith(
      'http://localhost:8001/dashboard/api/process_comment/3/',
      {
        headers: {
          _headers: {
            accept: ['application/json'],
            'content-type': ['application/json'],
          },
        },
        method: 'DELETE',
      }
    );
  });

  it('calls updateProcessComment', () => {
    QlfApi.updateProcessComment(3, 1, 'update comment');
    expect(fetch).toBeCalledWith(
      'http://localhost:8001/dashboard/api/process_comment/3/',
      {
        body: '{"text":"update comment","process":1}',
        headers: {
          _headers: {
            accept: ['application/json'],
            'content-type': ['application/json'],
          },
        },
        method: 'PUT',
      }
    );
  });

  it('calls getProcessComments', () => {
    QlfApi.getProcessComments(1);
    expect(fetch).toBeCalledWith(
      'http://localhost:8001/dashboard/api/process_comment/?process=1',
      {
        headers: {
          _headers: {
            accept: ['application/json'],
            'content-type': ['application/json'],
          },
        },
        method: 'GET',
      }
    );
  });

  it('calls sendTicketMail', () => {
    QlfApi.sendTicketMail('hawk@tes.com', 'test', 'problem', 'hawk');
    expect(fetch).toBeCalledWith(
      'http://localhost:8001/send_ticket_email/?format=json&email=hawk@tes.com&message=test&subject=problem&name=hawk',
      {
        headers: {
          _headers: {
            accept: ['application/json'],
            'content-type': ['application/json'],
          },
        },
        method: 'GET',
      }
    );
  });
});
