From 6942979a4013c3fc5184ea1a24ae4d542ae1f234 Mon Sep 17 00:00:00 2001 From: Robert Mogos Date: Fri, 22 Mar 2019 14:46:10 +0100 Subject: [PATCH] fix(ua): change the User-Agent to use the new specs lib (version) (#650) --- src/components/__tests__/InstantSearch.js | 8 +++++--- src/util/createInstantSearchComponent.js | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/__tests__/InstantSearch.js b/src/components/__tests__/InstantSearch.js index 84f78b559..b727f89fd 100644 --- a/src/components/__tests__/InstantSearch.js +++ b/src/components/__tests__/InstantSearch.js @@ -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()); @@ -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})` ); }); diff --git a/src/util/createInstantSearchComponent.js b/src/util/createInstantSearchComponent.js index e15bf7b7a..a1c919e4e 100644 --- a/src/util/createInstantSearchComponent.js +++ b/src/util/createInstantSearchComponent.js @@ -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( @@ -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})`); } },