Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ua): Update the User-Agent to use the new format #3616

Merged
merged 4 commits into from
Mar 22, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/InstantSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ See: https://www.algolia.com/doc/guides/building-search-ui/going-further/backend
}

if (typeof searchClient.addAlgoliaAgent === 'function') {
searchClient.addAlgoliaAgent(`instantsearch.js ${version}`);
searchClient.addAlgoliaAgent(`instantsearch.js (${version})`);
}

this.client = searchClient;
Expand Down
8 changes: 8 additions & 0 deletions src/lib/__tests__/InstantSearch-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import range from 'lodash/range';
import times from 'lodash/times';
import algoliaSearchHelper from 'algoliasearch-helper';
import InstantSearch from '../InstantSearch';
import version from '../version'
francoischalifour marked this conversation as resolved.
Show resolved Hide resolved

jest.mock('algoliasearch-helper', () => {
const module = require.requireActual('algoliasearch-helper');
Expand Down Expand Up @@ -151,6 +152,7 @@ describe('InstantSearch lifecycle', () => {
results: requests.map(() => ({})),
});
},
addAlgoliaAgent: jest.fn()
francoischalifour marked this conversation as resolved.
Show resolved Hide resolved
};

algoliasearch = jest.fn().mockReturnValue(client);
Expand All @@ -174,6 +176,7 @@ describe('InstantSearch lifecycle', () => {
});

afterEach(() => {
client.addAlgoliaAgent.mockClear();
algoliaSearchHelper.mockClear();
});

Expand All @@ -182,6 +185,11 @@ describe('InstantSearch lifecycle', () => {
expect(algoliasearch).toHaveBeenCalledWith(appId, apiKey);
});

it('calls addAlgoliaAgent', () => {
expect(client.addAlgoliaAgent).toHaveBeenCalledTimes(1);
expect(client.addAlgoliaAgent).toHaveBeenCalledWith(`instantsearch.js (${version})`);
francoischalifour marked this conversation as resolved.
Show resolved Hide resolved
});

it('does not call algoliasearchHelper', () => {
expect(algoliaSearchHelper).not.toHaveBeenCalled();
});
Expand Down