Skip to content

Commit

Permalink
chore: remove places tests (#1407)
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts committed May 17, 2022
1 parent 30518b0 commit 283e38c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 97 deletions.
52 changes: 3 additions & 49 deletions packages/algoliasearch/src/__tests__/default.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { createInMemoryCache } from '@algolia/cache-in-memory';
import { shuffle, version } from '@algolia/client-common';
import { SearchOptions } from '@algolia/client-search';
import {
createStatelessHost,
createUserAgent,
HostOptions,
RequestOptions,
} from '@algolia/transporter';

import { AlgoliaSearchOptions } from '..';
import { version } from '@algolia/client-common';
import { createStatelessHost, createUserAgent } from '@algolia/transporter';

import { TestSuite } from '../../../client-common/src/__tests__/TestSuite';

const algoliasearch = new TestSuite('search').algoliasearch;
Expand Down Expand Up @@ -179,43 +172,4 @@ describe('default preset', () => {
expect(client).toHaveProperty('destroy');
}
});

it('allows to use places', async () => {
const places = (appId: string = '', apiKey: string = '', options?: AlgoliaSearchOptions) => {
const placesClient = algoliasearch(appId, apiKey, {
hosts: ([{ url: 'places-dsn.algolia.net' }] as readonly HostOptions[]).concat(
shuffle([
{ url: 'places-1.algolia.net' },
{ url: 'places-2.algolia.net' },
{ url: 'places-3.algolia.net' },
])
),
...options,
});

return (query: string, requestOptions?: RequestOptions & SearchOptions) => {
return placesClient.transporter.read(
{
method: 'POST',
path: '1/places/query',
data: {
query,
},
cacheable: true,
},
requestOptions
);
};
};

const search = places('', '');

const results = await search('Portugal');

// @ts-ignore
expect(results.query).toBe('Portugal');

// @ts-ignore
expect(results.hits[0].country_code).toBe('pt');
});
});
51 changes: 3 additions & 48 deletions packages/algoliasearch/src/__tests__/lite.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { createInMemoryCache } from '@algolia/cache-in-memory';
import { shuffle, version } from '@algolia/client-common';
import { SearchOptions } from '@algolia/client-search';
import {
createStatelessHost,
createUserAgent,
HostOptions,
RequestOptions,
} from '@algolia/transporter';
import { version } from '@algolia/client-common';
import { createStatelessHost, createUserAgent } from '@algolia/transporter';

import algoliasearch, { AlgoliaSearchOptions } from '../builds/browserLite';
import algoliasearch from '../builds/browserLite';

const client = algoliasearch('appId', 'apiKey');

Expand Down Expand Up @@ -76,43 +70,4 @@ describe('lite preset', () => {
});
expect(customClient.transporter.hosts).toEqual([createStatelessHost({ url: 'foo.com' })]);
});

it('allows to use places', async () => {
const places = (appId: string = '', apiKey: string = '', options?: AlgoliaSearchOptions) => {
const placesClient = algoliasearch(appId, apiKey, {
hosts: ([{ url: 'places-dsn.algolia.net' }] as readonly HostOptions[]).concat(
shuffle([
{ url: 'places-1.algolia.net' },
{ url: 'places-2.algolia.net' },
{ url: 'places-3.algolia.net' },
])
),
...options,
});

return (query: string, requestOptions?: RequestOptions & SearchOptions) => {
return placesClient.transporter.read(
{
method: 'POST',
path: '1/places/query',
data: {
query,
},
cacheable: true,
},
requestOptions
);
};
};

const search = places('', '');

const results = await search('Portugal');

// @ts-ignore
expect(results.query).toBe('Portugal');

// @ts-ignore
expect(results.hits[0].country_code).toBe('pt');
});
});

0 comments on commit 283e38c

Please sign in to comment.