Skip to content

Commit 945c60f

Browse files
authored
Merge branch 'master' into feat/ql-type
2 parents 7ec9d9b + 283e38c commit 945c60f

File tree

2 files changed

+6
-97
lines changed

2 files changed

+6
-97
lines changed

packages/algoliasearch/src/__tests__/default.test.ts

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
import { createInMemoryCache } from '@algolia/cache-in-memory';
2-
import { shuffle, version } from '@algolia/client-common';
3-
import { SearchOptions } from '@algolia/client-search';
4-
import {
5-
createStatelessHost,
6-
createUserAgent,
7-
HostOptions,
8-
RequestOptions,
9-
} from '@algolia/transporter';
10-
11-
import { AlgoliaSearchOptions } from '..';
2+
import { version } from '@algolia/client-common';
3+
import { createStatelessHost, createUserAgent } from '@algolia/transporter';
4+
125
import { TestSuite } from '../../../client-common/src/__tests__/TestSuite';
136

147
const algoliasearch = new TestSuite('search').algoliasearch;
@@ -179,43 +172,4 @@ describe('default preset', () => {
179172
expect(client).toHaveProperty('destroy');
180173
}
181174
});
182-
183-
it('allows to use places', async () => {
184-
const places = (appId: string = '', apiKey: string = '', options?: AlgoliaSearchOptions) => {
185-
const placesClient = algoliasearch(appId, apiKey, {
186-
hosts: ([{ url: 'places-dsn.algolia.net' }] as readonly HostOptions[]).concat(
187-
shuffle([
188-
{ url: 'places-1.algolia.net' },
189-
{ url: 'places-2.algolia.net' },
190-
{ url: 'places-3.algolia.net' },
191-
])
192-
),
193-
...options,
194-
});
195-
196-
return (query: string, requestOptions?: RequestOptions & SearchOptions) => {
197-
return placesClient.transporter.read(
198-
{
199-
method: 'POST',
200-
path: '1/places/query',
201-
data: {
202-
query,
203-
},
204-
cacheable: true,
205-
},
206-
requestOptions
207-
);
208-
};
209-
};
210-
211-
const search = places('', '');
212-
213-
const results = await search('Portugal');
214-
215-
// @ts-ignore
216-
expect(results.query).toBe('Portugal');
217-
218-
// @ts-ignore
219-
expect(results.hits[0].country_code).toBe('pt');
220-
});
221175
});

packages/algoliasearch/src/__tests__/lite.test.ts

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
import { createInMemoryCache } from '@algolia/cache-in-memory';
2-
import { shuffle, version } from '@algolia/client-common';
3-
import { SearchOptions } from '@algolia/client-search';
4-
import {
5-
createStatelessHost,
6-
createUserAgent,
7-
HostOptions,
8-
RequestOptions,
9-
} from '@algolia/transporter';
2+
import { version } from '@algolia/client-common';
3+
import { createStatelessHost, createUserAgent } from '@algolia/transporter';
104

11-
import algoliasearch, { AlgoliaSearchOptions } from '../builds/browserLite';
5+
import algoliasearch from '../builds/browserLite';
126

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

@@ -76,43 +70,4 @@ describe('lite preset', () => {
7670
});
7771
expect(customClient.transporter.hosts).toEqual([createStatelessHost({ url: 'foo.com' })]);
7872
});
79-
80-
it('allows to use places', async () => {
81-
const places = (appId: string = '', apiKey: string = '', options?: AlgoliaSearchOptions) => {
82-
const placesClient = algoliasearch(appId, apiKey, {
83-
hosts: ([{ url: 'places-dsn.algolia.net' }] as readonly HostOptions[]).concat(
84-
shuffle([
85-
{ url: 'places-1.algolia.net' },
86-
{ url: 'places-2.algolia.net' },
87-
{ url: 'places-3.algolia.net' },
88-
])
89-
),
90-
...options,
91-
});
92-
93-
return (query: string, requestOptions?: RequestOptions & SearchOptions) => {
94-
return placesClient.transporter.read(
95-
{
96-
method: 'POST',
97-
path: '1/places/query',
98-
data: {
99-
query,
100-
},
101-
cacheable: true,
102-
},
103-
requestOptions
104-
);
105-
};
106-
};
107-
108-
const search = places('', '');
109-
110-
const results = await search('Portugal');
111-
112-
// @ts-ignore
113-
expect(results.query).toBe('Portugal');
114-
115-
// @ts-ignore
116-
expect(results.hits[0].country_code).toBe('pt');
117-
});
11873
});

0 commit comments

Comments
 (0)