Skip to content

Commit

Permalink
fix: remove a warning about insights that is not relevant anymore (#4593
Browse files Browse the repository at this point in the history
)

* fix: remove a warning about insights that is not relevant anymore

* remove unused import
  • Loading branch information
Eunjae Lee committed Dec 1, 2020
1 parent a1bd5cf commit b5f6a47
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 62 deletions.
12 changes: 0 additions & 12 deletions src/lib/InstantSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
MiddlewareDefinition,
RenderState,
} from '../types';
import hasDetectedInsightsClient from './utils/detect-insights-client';
import {
createRouterMiddleware,
RouterProps,
Expand Down Expand Up @@ -194,17 +193,6 @@ See: https://www.algolia.com/doc/guides/building-search-ui/going-further/backend
For more information, visit https://www.algolia.com/doc/guides/getting-insights-and-analytics/search-analytics/click-through-and-conversions/how-to/send-click-and-conversion-events-with-instantsearch/js/`
);

warning(
Boolean(insightsClient) || !hasDetectedInsightsClient(),
withUsage(`InstantSearch detected the Insights client in the global scope.
To connect InstantSearch to the Insights client, make sure to specify the \`insightsClient\` option:
const search = instantsearch({
/* ... */
insightsClient: window.aa,
});`)
);

if (insightsClient && typeof insightsClient !== 'function') {
throw new Error(
withUsage('The `insightsClient` option should be a function.')
Expand Down
50 changes: 0 additions & 50 deletions src/lib/__tests__/InstantSearch-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,56 +96,6 @@ See: https://www.algolia.com/doc/guides/building-search-ui/going-further/backend
See documentation: https://www.algolia.com/doc/api-reference/widgets/instantsearch/js/"
`);
});
describe('when insights client is detected', () => {
const warningMessage = `[InstantSearch.js]: InstantSearch detected the Insights client in the global scope.
To connect InstantSearch to the Insights client, make sure to specify the \`insightsClient\` option:
const search = instantsearch({
/* ... */
insightsClient: window.aa,
});
See documentation: https://www.algolia.com/doc/api-reference/widgets/instantsearch/js/`;

it('throws a warning if insightsClient was not passed', () => {
warning.cache = {};

const AlgoliaAnalyticsObject = 'aa';
global.AlgoliaAnalyticsObject = AlgoliaAnalyticsObject;
global[AlgoliaAnalyticsObject] = jest.fn();

expect(() => {
// eslint-disable-next-line no-new
new InstantSearch({
indexName: 'indexName',
searchClient: createSearchClient(),
});
}).toWarnDev(warningMessage);

delete global.AlgoliaAnalyticsObject;
delete global[AlgoliaAnalyticsObject];
});

it('does not throw a warning if insightsClient was passed', () => {
warning.cache = {};

const AlgoliaAnalyticsObject = 'aa';
global.AlgoliaAnalyticsObject = AlgoliaAnalyticsObject;
global[AlgoliaAnalyticsObject] = jest.fn();

expect(() => {
// eslint-disable-next-line no-new
new InstantSearch({
indexName: 'indexName',
searchClient: createSearchClient(),
insightsClient: jest.fn(),
});
}).not.toWarnDev(warningMessage);

delete global.AlgoliaAnalyticsObject;
delete global[AlgoliaAnalyticsObject];
});
});

it('throws if addWidgets is called with a single widget', () => {
expect(() => {
Expand Down

0 comments on commit b5f6a47

Please sign in to comment.