<commit_before>import panoPreview from './pano-preview';

describe('panoPreview service', () => {
  it('should return an object filled with data if response is ok', () => {
    fetch.mockResponseOnce(JSON.stringify({
      pano_id: 'pano_id',
      heading: 'heading',
      url: 'url'
    }));
    panoPreview({ latitude: 123, longitude: 321 }).then((res) => {
      expect(res).toEqual({
        id: 'pano_id',
        heading: 'heading',
        url: 'url'
      });
    });
    expect(fetch).toHaveBeenCalledWith('https://acc.api.data.amsterdam.nl/panorama/thumbnail/?lat=undefined&lon=321&width=438&radius=180');
  });

  it('should return an empty object when status is 404', () => {
    fetch.mockResponseOnce('{}', { status: 404 });
    panoPreview({ latitude: 123, longitude: 321 }).then((res) => {
      expect(res).toEqual({});
    });
  });

  it('should throw an error is response != ok and status != 404', async () => {
    fetch.mockResponseOnce('{}', { status: 503 });
    // const result =
    expect(panoPreview({
      latitude: 123,
      longitude: 321
    })).rejects.toEqual(new Error('Error requesting a panoramic view'));
  });
});
<commit_msg>test updated to reflect proper url<commit_after>import panoPreview from './pano-preview';

describe('panoPreview service', () => {
  it('should return an object filled with data if response is ok', () => {
    fetch.mockResponseOnce(JSON.stringify({
      pano_id: 'pano_id',
      heading: 'heading',
      url: 'url'
    }));
    panoPreview({ latitude: 123, longitude: 321 }).then((res) => {
      expect(res).toEqual({
        id: 'pano_id',
        heading: 'heading',
        url: 'url'
      });
    });
    expect(fetch).toHaveBeenCalledWith('https://acc.api.data.amsterdam.nl/panorama/thumbnail/?lat=123&lon=321&width=438&radius=180');
  });

  it('should return an empty object when status is 404', () => {
    fetch.mockResponseOnce('{}', { status: 404 });
    panoPreview({ latitude: 123, longitude: 321 }).then((res) => {
      expect(res).toEqual({});
    });
  });

  it('should throw an error is response != ok and status != 404', async () => {
    fetch.mockResponseOnce('{}', { status: 503 });
    // const result =
    expect(panoPreview({
      latitude: 123,
      longitude: 321
    })).rejects.toEqual(new Error('Error requesting a panoramic view'));
  });
});

{'fraction_non_alphanumeric': 0.18104547386315342, 'fraction_numerical': 0.034424139396515084, 'mean_word_length': 3.218637992831541, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1443512', 'n_tokens_mistral': 812, 'n_tokens_neox': 727, 'n_words': 173}