Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
fix(ua): change the User-Agent to use the new specs lib (version) (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmogos authored Mar 22, 2019
1 parent 84c909d commit 6942979
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/__tests__/InstantSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Vue from 'vue';
import { mount } from '@vue/test-utils';
import instantsearch from 'instantsearch.js/es';
import InstantSearch from '../InstantSearch';
import { version } from '../../../package.json';

beforeEach(() => jest.clearAllMocks());

Expand Down Expand Up @@ -245,9 +246,10 @@ it('will call client.addAlgoliaAgent if present', () => {
},
});

expect(client.addAlgoliaAgent).toHaveBeenCalledTimes(1);
expect(client.addAlgoliaAgent.mock.calls[0][0]).toMatch(
/Vue InstantSearch \([a-z0-9.-]+\)/
expect(client.addAlgoliaAgent).toHaveBeenCalledTimes(2);
expect(client.addAlgoliaAgent).toHaveBeenCalledWith(`Vue (${Vue.version})`);
expect(client.addAlgoliaAgent).toHaveBeenCalledWith(
`Vue InstantSearch (${version})`
);
});

Expand Down
2 changes: 2 additions & 0 deletions src/util/createInstantSearchComponent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createSuitMixin } from '../mixins/suit';
import { version } from '../../package.json'; // rollup does pick only what needed from json
import { _objectSpread } from './polyfills';
import Vue from 'vue';

export const createInstantSearchComponent = component =>
_objectSpread(
Expand Down Expand Up @@ -37,6 +38,7 @@ export const createInstantSearchComponent = component =>
created() {
const searchClient = this.instantSearchInstance.client;
if (typeof searchClient.addAlgoliaAgent === 'function') {
searchClient.addAlgoliaAgent(`Vue (${Vue.version})`);
searchClient.addAlgoliaAgent(`Vue InstantSearch (${version})`);
}
},
Expand Down

0 comments on commit 6942979

Please sign in to comment.