<commit_before>import test from 'ava';
import Provider from '../googleProvider';

test('Can fetch results with Google Provider', async (t) => {
  const provider = new Provider();

  const results = await provider.search({ query: 'netherlands' });
  const result = results[0];

  t.truthy(result.label);
  t.true(result.x > 5 && result.x < 6);
  t.true(result.y > 50 && result.y < 55);
  t.true(result.bounds[0][0] > result.bounds[0][1]);
  t.true(result.bounds[1][0] > result.bounds[1][1]);
  t.true(result.bounds[0][0] < result.bounds[1][0]);
  t.true(result.bounds[0][1] < result.bounds[1][1]);
});

test('Can get localized results', async (t) => {
  const provider = new Provider({
    params: {
      language: 'nl',
    },
  });

  const results = await provider.search({ query: 'leeuwarden' });
  t.is(results[0].label, 'Leeuwarden, Nederland');
});

test.skip('Can fetch results with API Key', async (t) => {
  const provider = new Provider({
    params: {
      key: process.env.GOOGLE_API_KEY,
    },
  });

  const results = await provider.search({ query: 'nederland' });
  const result = results[0];

  t.truthy(result.label);
});<commit_msg>test: bypass google tests when no api key has been provided<commit_after>import test from 'ava';
import Provider from '../googleProvider';

async function testFetch(t) {
  const provider = new Provider({
    params: {
      key: process.env.GOOGLE_API_KEY,
    },
  });

  const results = await provider.search({ query: 'netherlands' });
  const result = results[0];

  t.truthy(result.label);
  t.true(result.x > 5 && result.x < 6);
  t.true(result.y > 50 && result.y < 55);
  t.true(result.bounds[0][0] > result.bounds[0][1]);
  t.true(result.bounds[1][0] > result.bounds[1][1]);
  t.true(result.bounds[0][0] < result.bounds[1][0]);
  t.true(result.bounds[0][1] < result.bounds[1][1]);
}

async function testLocalizedResults(t) {
  const provider = new Provider({
    params: {
      key: process.env.GOOGLE_API_KEY,
      language: 'nl',
    },
  });

  const results = await provider.search({ query: 'leeuwarden' });
  t.is(results[0].label, 'Leeuwarden, Nederland');
}

if (process.env.GOOGLE_API_KEY) {
  test('Can fetch results with Google Provider', testFetch);
  test('Can get localized results', testLocalizedResults);
}
else {
  test.skip('Can fetch results with Google Provider', testFetch);
  test.skip('Can get localized results', testLocalizedResults);
}
{'fraction_non_alphanumeric': 0.17630057803468208, 'fraction_numerical': 0.02023121387283237, 'mean_word_length': 4.037422037422037, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 14, 'https://': 0, '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': '520738', 'n_tokens_mistral': 856, 'n_tokens_neox': 819, 'n_words': 195}